Comments in C programming Language | Single line Comments and Multi-line Comments in C language



In our previous article, We discussed the “Datatypes in C Language”. In todays article, We will look into the Comments in C programming and different types of comments.

Comments in C Language:

Comments are the sequence of Characters which doesn’t have any meaning to computer. In other words Compiler ignores comments, In fact, comments will not go to Translation stage which are Removed by C language Pre-processor while Preprocessing.

Comments are used to explain how the block of code is implemented. Usually, programmers write a short explanation about the program, So that source code will be more readable and understandable to the other programmers and colleagues.

Commenting code is one of the most important coding practice because it helps others to understand what you’re trying to do. Comments Increases the Readability of program.

📢. Comments are Useful Description about the program logic. Comments in C are Ignored by the C Compiler.

Many times, Programmers work on different projects and there is good possibility of forgetting the logic which is written by us as well. So In a way comments also helps us to recall the logic of the program.

We have two types of comments in C programming, They are.

  • Single Line Comments.
  • Multi line Comments.

Let’s see how to create single line comments and multi-line comments.

Single Line Comments in C Language :

We can create a Single Line comment using the Two forward slashes ( //)

The Single Line Comments Starts with Two Forward Slashes ( //) and Ends with Newline Character ( '\n') character.

As the name suggests, The single line comments Maximum length is One Line only.

Syntax of Single Line Comment:

As you can see from above syntax, "Your comment goes here" is a comment and will be ignored by the C Compiler.

The int n; is not a comment and It is a valid C statement, Which will be executed by the compiler.

Example Program to demonstrate Single Line Comments:

Let’s write a program to calculate the sum of the two integer numbers.

Program Output:

We have used the single line comments extensively in the above program, Starting with

Then at each line we added a single-line comment demonstrating the meaning of that line of code.

In the above example program, All the lines which are started with two forward slashes ( //) are Single Line comments, Which will be ignored by the compiler.

Multi-Line Comments in C Language :

We can create the multi line comments using the combination of backslash ( /) and Asterisk or Star ( *) characters.

The Multi-line Comments are starts with Forward slash and asterisk (star) combination ( /* )  and Ends with Asterisk and forward slash Combination ( */). Everything Written in between these tokens are treated as Comments.

Syntax of Multi-Line comments:

As you can see from the syntax, The multi line comments starts with /* then you can continue the comments as many lines as you want. You can end the comment by using the */ character combination.

The multi line comments are also ignored by the compiler, Comments are only useful for programmers.

Example Program for the Multi-Line Comments in C :

We are going to create two multi line comments in this program.

Program Output:

In the above program, Everything which is in-between the /* and */ characters is a Multi line comment.

We have two multi line comments in above program those comments are

and second multi-line comment is


In this article, We have discussed about the comments in programming, What is use of comments and what are the different types of comments in C Programming Language.

Related Tutorials:


Hi Guys, I am Venkatesh. I am a programmer and an Open Source enthusiast. I write about programming and technology on this blog.

You may also like...

1 Response

  1. […] Pre-Processor Directives also removes the Comments.  […]

Leave a Reply