C Comments

Comments are the non-executable code used to provide documentation for the C program. Comments provide details about the code so that other users can easily understand the code by reading those comments.

In C Language, comments are beneficial especially for large programs. C Comments can occupy more than one line but cannot be nested.

Types of Comments

  1. Single-Line Comments
  2. Multi-Line Comments

1. Single-Line Comments in C

Single-Line Comments are used to comment out just Single Line in the Code. It is used to provide the Description of line.

Syntax

Single line comments are represented by double slash //.
The syntax for a Single comment is:

// Single Line comment will be written here

Example of Single Line Comment in C

Let’s see an example of a single-line comment in C.

#include 
int main() 
{
 // providing the message 
 printf("hello c");
 return 0;
}

Run: http://ideone.com/Zh4906

Tutorials Class - Output Window

hello c


2. Multi-Line Comments in C

In multi-line comments, we can insert the comment description of many lines. It can be placed anywhere in the program. The multi-line comment starts with /* and ends with */.

Syntax

The syntax for a Multi-Line comment is:
/* Multi Line comment will be written in between this */

Example of Multi-Line Comment
#include 
int main() 
{
  /* printing the message
            with the help of multiple line comments*/
 printf("hello c");
 return 0;
}

Run: http://ideone.com/Zh4906

Tutorials Class - Output Window

hello c


Congratulations! Chapter Finished. Learn more about the similar topics:
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.