C COMMENTS

Comments are hints that a programmer adds within its code so other person who looks at the code can understand it.

There are two types of comments in C language:

1. Single Line Comments

2. Multi Line Comments.

Single line Comments :

Single-line comments Start with double forward slashes(//).

Any text written after the forward slashes(//) will be ignored by the compiler (i.e., will not be executed).

Example:

//Program to add two numbers.

#include <stdio.h>
int main() {  

//declaring variable
    int number1, number2, sum;
    //print the sum of number1 and number2
    printf("Enter two integers: ");
    scanf("%d %d", &number1, &number2);

    // calculating sum
    sum = number1 + number2;      
    
    printf("%d + %d = %d", number1, number2, sum);
    return 0;
}

Multi-line comments:

Multi-line comments start with /* and ends with */.

Any textwritten between /* and */ will be ignored by the compiler.

Example:

/*Progrm in C to 
add two numbers.*/

#include <stdio.h>
int main() {   

//declaring variable
    int number1, number2, sum;
//print the sum of number1 and number2    
    printf("Enter two integers: ");
    scanf("%d %d", &number1, &number2);

    // calculating sum
    sum = number1 + number2;      
    
    printf("%d + %d = %d", number1, number2, sum);
    return 0;
}

}