English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

C Language Basic Tutorial

C Language Flow Control

C Language Functions

C Language Arrays

C Language Pointers

C Language Strings

C Language Structure

C Language File

C Other

C Language Reference Manual

C Language Comments

C language comments are used to provide information about the code line. They are widely used for recording code. There are two types of comments in C language.

  1. Single-line comments

  2. Multi-line Comments

Single-line comments

Single-line comments use double backslashes//Representation. Let's look at an example of a single-line comment in C language.

#include<stdio.h>    
int main() {    
    //Print Information 
    printf("Hello C");    
    return 0;  
}

Output:

Hello C

Even you can add comments after statements. For example:

printf("Hello C");//Print Information

Multi-line Comments

Multi-line comments use backslash asterisks/ * ... * /Representation. It can occupy multiple lines of code, but cannot be nested. Syntax:

/* 
To Comment
Code
*/

Let's see an example of a multi-line comment in C language.

#include<stdio.h>    
int main() {    
    /*Print Information
    Multi-line Comments*/  
    printf("Hello C");    
    return 0;  
}

Output:

Hello C