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

Spread the love
Comments in C Programming

Comments :

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 Pre-processor while Preprocessing.

Comments are used to Increase the Readability of program. They are used to explain the purpose of the statements and helpful for Understanding the program. If you are working with your team these comments will helpful for your team member to understand the code.

There are two types of Comments

  • Single Line Comments.
  • Multi-line Comments.

Single Line Comments :

Single Line Comments are Starts with two Forward Slashes ( // ). and Ends with Newline Character ( ‘\n’ ). These comments Maximum length is One Line that’s these are called as Single Line Comments.

Example :

 

In Above program  / / here I am taking Input from user is Single line Comment also all below three lines contains Single Line Comments.

Multi-Line Comments :

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

Example for Multi line Comments :

In above program, everything between the /* and */ is considered as comment.

/*

This is Multi line Comment

now am in second line of Multi line Comment

This entire three lines are Comments i.e multi line comments.

*/

      

Venkatesh Macha

Hi Guys, I am Venkatesh Macha. I am a programmer and an Open Source enthusiast, Presently working as a Software Engineer. Apart from that, I love to explore new technologies and things.

You may also like...

Leave a Reply