Ads block

Banner 728x90px

Comments in C

Comments play an important role in the program. It is a way to make a program understandable for others.

Comment lines are used only for the purpose of understanding not for the compilation. A compiler does not compile it and does not show on the display. Comments may be written in a single line or multiple lines.


Single Line Comments

Single line comments are represented by double slash //. We use these slash first and then start to write comment line. Let's see an example of a single line comment in C.

#include<stdio.h>
void main()
 {
  printf("hello world");   //To print statement
 }

hello world



Multi Line Comments

Multi line comments are represented by the symbol slash and astrisk /*....*/. To write multi line comments, line starts with '/*' and ends with '*/'.

To make it more clear we take an example.

/*This is basic program
  to print a statement*/

#include<stdio.h>
void main()
 {
  printf("hello world");
 }

hello world



In the next chapter, we will discuss about format specifiers.