Comments in C

Generally Comments are used to provide the description about the Logic written in program. Comments are not display on output screen. Comments are not read by Compiler.

  When we are used the comments, then that specific part will be ignored by compiler.

  There are 2 types of comments in C language

  1) Single Line Comments

  2) Multiple line comments


Single Line Comments

Single line comments can be provided by using / /....................


#include <stdio.h>
int main()
{
    //this is single line comment
    printf("Above line is single line comment");
    // printf("value of extern variable %d",myvariable);//printing the value of extern variable myvariable
    return 0;
}
Above line is single line comment

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:


#include <stdio.h>
int main()
{
    /*
    This program created by Durgesh
    on 25/04/2018
    While learning c

    */
    printf("Above line is Multi-line comment");
    return 0;
}
Above line is Multi-line comment
woman avatar