Comments in C

Comments

Comments in C

Comments in C language are used to provide information about lines of code. It is widely used for documenting code. There are 2 types of comments in the C language.

  1. Single Line Comments
  2. Multi-Line Comments

Single Line Comments

Single line comments are represented by double slash \\. Let’s see an example of a single line comment in C.

[cc lang=”bash” escaped=”true” width=”auto” nowrap=”0″ theme=”blackboard” line_numbers=”off” ]
#include
int main(){
//printing information
printf(“Hello C”);
return 0;
}        [/cc]

Output:

Hello C

Even you can place the comment after the statement. For example:

[cc lang=”bash” escaped=”true” width=”auto” nowrap=”0″ theme=”blackboard” line_numbers=”off” ]
printf”Hello C”//printing information[/cc]

Multi Line Comments

Multi-Line comments are represented by slash asterisk \* … *\. It can occupy many lines of code, but it can’t be nested. Syntax:
/*code
to be commented
*/
Let’s see an example of a multi-Line comment in C.
[cc lang=”bash” escaped=”true” width=”auto” nowrap=”0″ theme=”blackboard” line_numbers=”off” ]#include
int main(){
/*printing information
Multi-Line Comment*/
printf(“Hello C”);
return 0;
} [/cc]

Output:

Hello C

Related Post

Resignation Letter and Relieving Letter Resignation Letter Sample 1 Sender’s Name, Sender’s Address, Mobile Number, MailDate:ToThe Human Resource Department Company Name Company Addre...
How to use Flutter most usable Widgets | Flutter t... We need some basic widgets for creating our first flutter app. Widgets describe what their view should look like given their current configuration and...
Continue Statement in JAVA Continue Statement in JAVA Suppose you are working with loops. Sometime it is desirable terminate the loop or skip some statement inside the loop wit...
Getting started with C Getting started with C : If we want to communicate with our computer it is very much needed that our computer understands what we want to say to it. ...
Switch Case Statement Switch Case Statement The switch statement is a multi-way branch statement. It provides an easy way to dispatch execution to different parts of c...
Loop Control Statement Loop control statements are used when a section of code may either be executed a fixed number of times. C gives you a choice of three types of loop st...

Leave a Reply

Your email address will not be published. Required fields are marked *