Comments in the C language is used to provide information about lines of code. They are widely used for documenting code. There are two types of comments in the C language.
Single line comments are represented by double slash //. Let’s see an example of a single line comment in C.
// use two forward slashes to create a single comment
// This is a single line comment in code, compiler will not compile this line
#include<stdio.h>
int main()
{
// you can place single line comment anywhere in code, as per your need. Like-
//printing information
printf("Welcome to EzyLearning"); // Even you can place comment just after the end of ;
return 0;
}
Welcome to EzyLearning
A comment that begins with /* and ends with */ can be placed anywhere in your code, on the same line or multiple lines. This feature is useful for adding explanatory notes or temporarily disabling certain parts of the code for testing purposes. Just be mindful not to overuse comments, as they can clutter the code and make it harder to read.
/* Sample Multiline Comment
statement-Line 1
statement-Line 2
statement-Line 3
statement-Line 4
statement-Line 5
….
…
*/
#include <stdio.h>
int main()
{
/* in main function
one can write any dscription about the problem, code or a statement.
This comment can be of single or multiple lines.
programmer can also this paird character set /*.....*/ to hide a certain set of multi-line-statements
or block of code
*/
int i = 7; //x is a integer variable
printf("%d", i);
return 0;
}
7
Multi-line comments are mostly useful while you are debugging a large set of code, or you want to describe certain set of statements.
All about java servlets Part-2 What is a website? Website is a collection of related… Read More
Let's train the machine. Machine learning is a growing technology which enables computers to learn… Read More
“Unless you try to do something beyond what you have already mastered, you will never… Read More
Whenever you decide to start coding and you want to become budding coder or programmer… Read More
C components are essential elements of a C program, including comments, preprocessor directives, functions, statements,… Read More
All about java servlets Part-2 What is a website? Website is a collection of related… Read More