Comments in C


Comment use for the description of the program. You can also use comment when you do not want to use some code then use comment there.

Why use Comments in programming languages


Suppose you have 100 line of code temporarily you want to use 10 line of code then you will remove 90 line of code but suppose next time you need that code then you will have to type 90 line of code again. That’s while we use to comments.

How can i use Comment in C


There are two way where we can use Comment.


  • − Single Line Comments.
  • − Multi Line comments.

Single Line Comments


Single line comment use for single line of code. We use here \\ double slash.

  • Examples
#include<stdio.h> #include<conio.h> void main() { //Sum of two number and this line is commented here int x=10; int y=20; int s; clrscr(); s=x+y; printf(“The sum of two Number is %d”,s); getch(); }

Output is:-

The sum of two Number 30

Multi line comment

Multi line comment use for multiple line of code. When we want to skip multi line of code then we can use multi line comment.

  • Examples
#include<stdio.h> #include<conio.h> void main() { /* Sum of two number and this line is commented here with multi line comment */ int x=10; int y=20; int s; clrscr(); s=x+y; printf(“The sum of two Number is %d”,s); getch(); }

Output is:-

The sum of two Number 30