1. C Learning

Comments in C Programming Language

Comment use for the description of the program. You can also use comments when you do not want to use some code then use comments there.

Why use Comments in programming languages

Suppose you have 100 lines of code temporarily you want to use 10 lines of code then you will remove 90 lines of code but suppose next time.

you need that code then you will have to type 90 line of code again. That’s while we use comments.

How can i use Comment in C

There are two way where we can use Comment.

  • − Single Line Comments.
  • − Multi Line comments.

Single Line Comments

Single line comment use for single line of code. We use here \ double slash.

Example

#include<stdio.h>
#include<conio.h> 
void main()
 { //Sum of two number and this line is commented here
 int x=10; 
int y=20;
 int s; clrscr();
 s=x+y;
 printf(“The sum of two Number is %d”,s);
 getch(); 
}

Output is:-

The sum of two Number 30

Multi line comment

Multi-line comment use for multiple lines of code. When we want to skip a multi-line of code then we can use the multi-line comment.

Examples

#include<stdio.h>
#include<conio.h>
 void main()
 { /* Sum of two number and this line is commented here with multi line comment */
 int x=10; 
int y=20; int s; 
clrscr();
 s=x+y;
 printf(“The sum of two Number is %d”,s);
 getch(); }

Output is:-

The sum of two Number 30

If you like this post, don’t forget to share 🙂

This article is written by our awesome writer
Comments to: Comments in C Programming Language

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

Attach images - Only PNG, JPG, JPEG and GIF are supported.

New Dark Mode Is Here

Sign In to access the new Dark Mode reading option.

Explore Tutorials By Categories

Login

Welcome to Codeverb

Ready to learn something new?
Join Codeverb!

Read Smart, Save Time
  •  
    Strength indicator
  •  
  •  
    Log In | Lost Password