Comments in C

Comments in C

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.

#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:

C Programming Language

Features of C Programming Language

Variables in C

Data Types in C

Keywords in C

C Operators

Escape Sequence in C

C Functions

Storage Classes in C

Dynamic memory allocation in C

Factorial Program in C

Leap year program in C

Fibonacci Series in C

Prime Number program in C

Palindrome program in C

Sum of digits program in C

Escape Sequence in C

ASCII value in C

Difference Between Type Casting and Type Conversion in C

Difference Between Variables and Constants

Matrix multiplication in C

C Program to generate Fibonacci Triangle

C Program to print “hello” without semicolon

C Program to swap two numbers without third variable

C Program to reverse number

Count the number of digits in C

Tokens in C

C Identifiers

C Strings

Compile time vs Runtime in C

C break statement

C goto statement

Type Casting in C

C String Functions

C Pointers

Dangling Pointers in C

void pointer in C

Pointer to Pointer in C

Recursion in C

Call by value and Call by reference in C

File Handling in C

2 thoughts on “Comments in C

  1. Pingback: C fputc() and fgetc() - CloudNClear

  2. Pingback: C fprintf() and fscanf() - CloudNClear

Comments are closed.