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()
Chitra
Chitra

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the latest updates on your inbox

Be the first to receive the latest updates from Codesdoc by signing up to our email subscription.

    StudentProjects.in