Comments in C

Comments in C

#Generally Comments are used to provide the description about the Logic written in program. Comments are not display on output screen.
When we are used the comments, then that specific part will be ignored by compiler.
In 'C' language two types of comments are possible
  • Single line comments
  • Multiple line comments

Single line comments

Single line comments can be provided by using / /....................

Multiple line comments

Multiple line comments can be provided by using /*......................*/
Note: When we are working with the multiple line comments then nested comments are not possible.
comment in c

Rules for Writing Comments

1. Program contains any number of comments at any place.

Example

// header files
#include<stdio.h>
#include<conio.h>

void main()
{
// variable declaration
int a,b,c;
a=10;
b=20;
c=a+b;
printf("Sum= %d",c);
getch();
}
2. Nested Comments are not possible, that means comments within comments.

Example

void main()
{
/*
/*      comments   */
*/
}
3. Comments can be splits over more than one line.

Example

void main()
{
/* main   
   function
   body part
*/
}
4. Comments are not case sensitive.

Example

void main()
{

/*  MAIN Function BODY   */

}
5. Single line comments start with "//"

Example

void main()
{

// Single line comment

}

0 comments: