fastread homefastrread library fastread menu

C : Comments

Tutorial by:      Date: 2016-04-27 04:05:02

❰ Previous Next ❱

Comments in C language are used to provide information about lines of code. It is widely used for documenting code. There are 2 types of comments in C language.

  1. Single Line Comments
  2. Multi Line Comments

Single Line Comments

Single line comments are represented by double slash \\. Let's see an example of single line comment in C.

 
  1. #include <stdio.h>      
  2. #include <conio.h>    
  3. void main(){      
  4. clrscr();      
  5. //printing information  
  6. printf("Hello C");  
  7. getch();      
  8. }      

Output:

Hello C

Even you can place comment after statement. For example:

 
  1. printf("Hello C");//printing information  

Mult Line Comments

Multi line comments are represented by slash asterisk \* ... *\. It can occupy many lines of code but it can't be nested. Syntax:

 
  1. /*  
  2. code 
  3. to be commented 
  4. */  

Let's see an example of multi line comment in C.

 
  1. #include <stdio.h>      
  2. #include <conio.h>    
  3. void main(){      
  4. clrscr();      
  5. /*printing 
  6. information*/  
  7. printf("Hello C");  
  8. getch();      
  9. }      

Output:

Hello C

❰ Previous Next ❱


C

Submit Your Thought, Tutorial, Articls etc.

Submit Your Information India's Number one online promotion website