Comments in C | Full Notes |

In the C programming, comments acts as guideposts for your coding journey. They are lines of text purposefully ignored by the compiler, meaning they don’t affect how your program runs. These comments serve as explanations and annotations, making your code easier for you and others to understand. Think of them as friendly notes to yourself or future programmers, helping decipher the logic and purpose of different sections of code.

Inshort, Comments in C are non-executable portions of code used to provide explanations, documentation, or annotations within a program.

It is of two types

  1. Single Line Comments
  2. Multi LineComments

Single Line Comment

Single-line comments start with // and extend to the end of the line:

// This is a single-line comment
int x = 5; // This comment explains the variable assignment

Multi Level Comments

Multi-line comments are enclosed within /* */ and can span multiple lines:

/*
This is a multi-line comment
It can span across several lines
and is useful for longer explanations or notes
*/
int y = 10; /* Variable initialization */


In conclusion, comments in C provide invaluable documentation and explanatory notes within the code, enhancing readability and facilitating collaboration among developers. It helps the coders to provide useful information about the block of the code which is written.

Don't be a Chatur. Be the Rancho, Share it to your Friends also....