Comment in C
What is Comment in C?
In C comment is the explanation or description of the source code that is not executed as a part of the program.A comment makes the code more readable to the programmer.There are two types of Comment:
- Single Line Comment
- Multiline Comment
Single line comment
Single line comment is represented by double forward slashs //. Let's learn it with an example of a single line comment in C.
Example
#include<stdio.h>
#include<conio.h>
void main()
{
//printf() used to print the data on output screen
printf("Welcome to learn C");
getch();
}
Output
Multi Line Comments
Multi-Line comment start by forward slash asterisk and ends with asterisk forward slash /* ... */. It can occupy many or multi lines of code. Let's learn it with an example of a multi line comment in C.
Syntax:
/*
Write the code
to be commented
*/
Example
#include<stdio.h>
#include<conio.h>
void main()
{
/* printf() is used to print
the data on output screen */
printf("Welcome to learn C");
getch();
}