What is Comment in C Programming Language ?

comment in c

In this article we will going to discuss about Comment in C language in which following topic are included,

  • Comment in C.
  • Why we use comment in C ?
  • Types of comment in C.

Comment in C:

Comment in C language is nothing but, it is type of arguments which is used in C program by using symbol like (//) and (/*, */). and it is non executable argument(statement) which means comment are not consider by the compiler during execution of the program but, It is optional case.

Why we use comment in C ?

Comments are use in C program because it help to understand  about code and it is very useful in long program with the help of comment programmer can indicate each block of code which are used in program with help of which user/reader can easily understand which blocks of code are perform what kind of task.

Types of comment in C:

There are two types of comment in C language:
  1. Single-line Comment
  2. Multi-line Comment

1.Single line comment:

This comment are used in C language by using double backward slash(//) and it is used only when programmer want to comment in Single line for example ,

int main()
{
  int a , b , c;

  printf("\n Enter the two number ");     // taking input
  scanf("%d%d",&a,&b);

   c=a+b;                                                       // addition 

  printf("\n The sum of two number %d", c); // output
  return 0;   
}

2.Multi line comment:

This comment used in C when programmer want make blocks of codes as comment and it is denoted by backward slash and asterisk at initial and asterisk and backward slash at the end of the block or line(/*...............*/) for example,

int main()
{
  int a , b , c;

/*  printf("\n Enter the two number ");            
     scanf("%d%d",&a,&b);

      c=a+b;                                                       

     printf("\n The sum of two number %d", c); 
     return 0;   */
}
here 5 line become as comment which has no meaning in this main() function.

Conclusion:

So, i hope after reading this article you have understand about comment in C language in detail but still if you have any queries then write in comment section.

Post a Comment (0)
Previous Post Next Post