Comments in C
In C programming, comments are used to describe the functionality of code, making it easier for programmers to understand the code. Comments are ignored by the compiler and do not affect the execution of the program.
C supports two types of comments:
- Single-line Comments:
- Multi-line Comments:
1) Single Line Comments
Single line comments are represented by double slash . Let's see an example of a single line comment in C.
C Program Example
#include <stdio.h>
int main()
{
//printing information
printf("Hello C");
return 0;
}
Output
Hello C
2) Multi-line Comments
Multi-Line comments are represented by slash asterisk * ... *. It can occupy many lines of code, but it can't be nested. Syntax:
C Program Example
#include <stdio.h>
int main()
{
/*printing information
Multi-Line Comment*/
printf("Hello C");
return 0;
}
Output
Hello C