Comments In C Language

Comments in C language are used for understanding purpose. Comments are ignored by the compiler. Comments can appear wherever and whenever you want in a C program. In C language there are two types of comments viz. single line comment and multiline comments. We can write single line comments preceding with '//' (without quotes). To write a multiline comment we have to enclose it in '/*' and '*/' (without quotes).

Example of single line comment:

#include <stdio.h>

int main()
{
// I am a single line comment.
printf("Hello World!");
}

Example of multi line comment:

/* We can also use multiline type to write single line comments but vice versa is will create an error. */

#include <stdio.h>

// Look I can appear anywhere in C program.

int main()
{

/* I am a multiline comment. I will remain a comment 
even if written on this next line. */

printf("Hello World!");

}

Prev - Your First C Program Next - Variables and data types in C