COMMENTS IN C

Suriya Ravichandran



Comments In C

In C programming, comments are used to annotate the code with explanations, notes, or any other information that is meant for human readers and is ignored by the compiler during the compilation process. Comments are essential for improving code readability, understanding, and maintenance.

Types Of Comments In C

There are two types of comments in C:


Single-Line Comments: 

Single-line comments begin with two consecutive forward slashes (//). Anything following // on the same line is considered a comment and is ignored by the compiler.

Example:


  // This is a single-line comment
  int x = 5; // This is also a single-line comment



Multi-Line Comments: 

Multi-line comments, also known as block comments, are enclosed between /* and */. They can span across multiple lines and can contain text spanning multiple lines.

Example:



  /* This is a multi-line
     comment */
  int y = 10;
  /* 
     This is another multi-line
     comment 
  */





More topic in C

Tags
Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send