C Comments

Comments makes a program more readable and provide clarity to the C code. Comments are widely used for documenting C code.

C Comments
C Comments

Comments make a program more readable and provide clarity to the C code. Comments are widely used for documenting C code.

In C programming language comments are statements that are not executed by the compiler. A comment can include any combination of characters and comments can appear anywhere and it allows white-space characters.

There are two types of comments. They are,

  • Single line comment
  • Multi-line comment

Single line comment

Single line comment is used to comment a single line of code. A single-line comment starts with a double slash(//).

Example:

#include
int main()
{
//This is an example for single line comment
printf("Welcome To C Tutorial");    //This is an printing statement
return 0;  //This is an returning statement
}   

Output:

Welcome To C Tutorial

Multi-line comment

Multi-Line comments are used to comment on more than one line of code. Multi-Line comments start with forwarding slash and asterisk (/*) and end with asterisk and forward-slash (*/). Everything after the forward-slash and asterisk (/*) symbol will be commented until it reaches the asterisk and forward-slash (*/) symbol.

Example:

#include
int main(){
/* This is an example for
Multi-Line Comment*/
printf("Welcome To C Tutorial");
return 0;
}  

Output:

Welcome To C Tutorial