Comments in C language are used to provide information about lines of code. It is widely used for documenting code. A well-documented program is a good practice for a programmer. In computer programming, a comment is a programmer-readable explanation or annotation in the source code of a computer program. Comments are statements that are not executed by the compiler and interpreter.
There are 2 types of comments in the C language
- Single Line Comments
- Multi-Line Comments
1. Single Line Comments
Single line comments are represented by a double slash \\. Let's see an example of a single-line comment in C.
Ex:-
#include<stdio.h>
#include<conio.h>
void main()
{
//printing information
printf("Hello C");
getch();
}
2. Multi-Line Comments
Multi-Line comments are represented by a slash asterisk /* ... */. It can occupy many lines of code, but it can't be nested.
Ex:-
#include<stdio.h>
#include<conio.h>
void main()
{
/*printing information Multi-Line Comment*/
printf("Hello C");
getch();
}
0 Comments