Thursday

Comments in C++

Comments :-
                                      In C++ programming language comments are the single line or multiple (more then one) line statements which are used by the programmer for his own assistance (help) are known as comments.



And they are totally ignored by the compiler. In it programmer can write anything by which he can be helped. In C++ programming language comments are commonly used to highlight something and also have a proper syntax in which they are written down.

There are two types of comments :

1) Single line comments :-
                                 As it is clear by it's name that the comments which depend upon one line are called single line comments and it's length never exceeds from one line. And it's syntax is the comment is written after double forward slashes //. 
For example :
// This line includes header file which is <iostream>.
#include <iostream>    

2) Multiple line comments :-
                                        The comments which depend upon more then one line are called multiple line comments. And regarding it's length there is no restriction it's length can exceed any limit. It's syntax is it starts with /* and ends with */.
For example :
/* int main ( ) is starting point of a program and in cout that line is written which has to be printed and semicolons are the statement terminators. */
int main ( )
{
  cout<< " Welcome ";
  return o;
}





No comments:

Post a Comment