C comments are used to give a brief description about any specific line of code or about a module in the code to make the code more user-friendly.
C Comments can be of two types:
- Single line Comments
- Multi line Comments
Single Line Comments:
Single line comments can be used for commenting a line of the code or to write a single line description about the code. The lines starting with // is considered as single line comment.
Multi Line Comments:
Multi line comments can be used for commenting a part of the code or to write a multiple lines description about the code. The lines enclosed between /* */ are considered as multi line comments.
Example:
#include <stdio.h> int main() { // Performing Arithmetic Operations without using brackets. int sum1 = 10+20*10-90*10+700; /* Performing Arithmetic Operations using brackets to clarify the expression.*/ int sum2 = (10+20)*10-(90*10)+700; printf ("%d", sum1); printf ("\n"); printf ("%d", sum2); return 0; } |
Output
10 100 |