Comments in C language

Comments are merely program documentation which helps the reader to understand the code.
The compiler ignores these comments when it translates the program into executable code.
C language uses two different formats of comment
1. Block comment
2. Line comment

1. Block comment: A block comment is used when the comment will span several lines.
Example:

 /*This is a block comment
                    that covers two lines*/

2. Line comment: The line comment uses two slashes (//).Programmers generally use this format for short comments.
Example:

//This is a single line comment

Example program:

1
2
3
4
5
6
7
8
9
/*This is a Greeting program, which prints ‘Hello world’. 
This program demonstrates some of the components of a simple c program*/ 
#include “stdio.h”
#include “conio.h”
void main()
{
printf(“Hello World”);  //This statement prints Hello World
getch();
}//main()

Leave a Reply