Subscribe

Header Ads

How to write comments in C programming?



We use comments in C program to make the program easy to understand by the other programmer (also if we work on it after a long time then the comments will help us to understand program).

We use to write comments in program in our own language because the compiler do not compile that part of program (it do not show any error).  

Types of comments in C :-

a) Single line comment.

b) Multiline comment

a) Single Line Comment:-   

When we are going to write a comment which will not take more then one line then we use single line comment.

It starts with '// ' (double slash) and after that the compiler will not compile that line to the end.

b) Multi Line comment:-

When we are going to write a comment which will take more then 1 line  then we will use multi line comment.

It starts with /* and it  ends with */.

This program will make your doubts more clear


/* This is multi line comment*/

#include<stdio.h>

int main()

{

        printf("Hello World.");  // This is single line comment.  

        return 0;      

}



Post a Comment

0 Comments