TRENDING TOPICS

×

Comments in c

Comments in C programming and types of comments in C

In C programming comments are used to ignore lines of code, at the place of lines of code you can insert a meaningful message as a remark.

  • C compiler skips commented lines.
  • The line just next to the comment mark gets ignored by the compiler.
  • It is best practice to use comments to remark that the code is about what so that in future anyone can understand why that block of code has been written.

Types of Comments in C

There are two types of comments in C programming.

  • Single Line Comment
  • Multiline Comment

Single Line Comment

In C programming single line comment is used to ignore only one line of code. Symbol // is used to define single-line comment. In a line, the content which is written after // symbol is get ignored by the compiler.

Syntax

// single line commented statement..

Example

Output

* In the above example, you can see, the code followed by // symbol are got ignored by the compiler

2. Multiline Comment

The multiline comment is also used to ignore the code, the only difference is that it can ignore more than one lines of code at a time.

  • In this the whole code written between /* and */ symbols.
  • It can also be used as a single line comment.
  • The comment scope start with /* symbol and ends with */

Syntax

/* commented line 1
commented line 2
...........
commented line n */

Example

Output

Note: You can use many numbers of single line / multiline or both type of comments in a C program.

Advertise With Us

We offer sponsored posts and guest posts with do-follow links, back-links, and other advertising services, To advertise email us at "advertise@gdatamart.com"

© 2021 GDATAMART.COM (All Rights Reserved)