Home >>C Tutorial >Comments in C

Comments in C

Comments in C

The Comments in C language are basically used to provide the information about lines of the code and are majorly used for documenting the code. There are generally two types of comments in the C language:

  • Single Line Comments
  • Multi-Line Comments

1. Single Line Comments

The Single line comments in C language are generally represented by double backward slashes \\.
Here is an example of a single line comment in C.

#include<stdio.h>    
int main()
{ 
//printing information    
printf("Hello there");    
return 0;  
}  
Output :Hello there

2. Multi line comments in C

The Multi-Line comments in C language are generally represented by the backward slash asterisk /* ... */. Many lines of the code can be occupied by the multi-line comments but they can’t be nested.

Here is the syntax for the same:

 /*  
code 
to be commented 
*/  
 

Here is an example of a multi-line comment in the C language:

 #include<stdio.h>    
int main()
{    
    /*printing information   
      Multi-Line Comment
	  */  
printf("Hello There");    
return 0;  
}       
 
Output :Hello there

No Sidebar ads