C Comments
Comments are used to describe the code. These lines are not displayed in the website. It offers an option of leaving notes for yourself or others. The comment simplifies the production of more readable code. There are two types of C programming comments:
- Single-line Comment
- Multi-line Comment
Single-line Comment
A single-line comment is represented by //. It is used for commenting a single line.
Example
#include <stdio.h>
int main()
{
// This is a single line comment
printf("Hello, World!");
return 0;
}
Output:
Hello, World!
Multi-line Comment
Multi-line comments open with /* and close with */.
Example
#include <stdio.h>
int main()
{
/* This is a
multi-line comment */printf("Hello, World!");
return 0;
}
Output:
Hello, World!