Comments are used to give additional useful information inside a C Program. Comments are optional and are just used to increase the readability of the program. Comments in the source code are ignored by the compiler.
There are 2 types of comments in the C language.
Single line comments are represented by double slash //
. Let's see an example of a single line comment in C.
Prefix "//" before the text which needs to be commented //
#includeint main(){ //printing information printf("Hello C"); return 0; }
Even you can place the comment after the statement. For example:
printf("Hello C");//printing information
Multi-Line comments are represented by slash asterisk \* ... *\
. It can occupy many lines of code, but it can't be nested.
/* code to be commented */
Let's see an example of a multi-Line comment in C.
#includeint main(){ /*printing information Multi-Line Comment*/ printf("Hello C"); return 0; }