C Comments

Comments are pieces of information describing about a software or module. They are ignored by the compiler and do not affect the output of the program. Comments are added to make code much more readable and maintainable.

C offers two kinds of commenting styles, single line comment, denoted by “// …”and multi line comment, denoted by “/* … */”, where the ellipses denotes the comment. Also, both C and C++ have the same commenting style.

Single Line Comment

// This is a single line comment.

Multi-Line Comment

/* This is a 
   Multi-Line comment.
*/

Multi-Line comments can be made fancier by adding asterisk at the beginning of each line. The following example shows the usage of comments in a program.

/* Comments
 * are
 * cool
 */
#include<stdio.h>
int main(void)
{ 
    // Prints "Hello World!"
    printf("Hello World!"); 
   return 0;
}

Trending

C Programming

Remember to follow community guidelines and don't go off topic.