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.
- Single Line Comments
- 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.
#include<stdio.h>
int main(){
//printing information
printf(“Hello C”);
return 0;
}
Output:
Hello C
Even you can place the comment after the statement. For example:
printf(“Hello C”);//printing information
Mult 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.
#include<stdio.h>
int main(){
/*printing information
Multi-Line Comment*/
printf(“Hello C”);
return 0;
}
Output:
Hello C
Related Post:
Features of C Programming Language
Dynamic memory allocation in C
Difference Between Type Casting and Type Conversion in C
Difference Between Variables and Constants
C Program to generate Fibonacci Triangle
C Program to print “hello” without semicolon
C Program to swap two numbers without third variable
Count the number of digits in C