🌟 Join our Telegram group for exclusive updates! Join Now Get Involved

C Comments

C Comments

Comments in C

Comments can be used to insert any informative piece which a programmer does not wish to be executed. It could be either to explain a piece of code or to make it more readable. In addition, it can be used to prevent the execution of alternative code when the process of debugging is done. Comments can be singled-lined or multi-lined.

Single Line Comments

  • Single-line comments start with two forward slashes (//).
  • Any information after the slashes // lying on the same line would be ignored (will not be executed).

An example of how we use a single-line comment:

        
#include <stdio.h>

int main() {
    // This is a single line comment
    printf("Hello World!");
    return 0;
}
        
    

Multi-line Comments

  • A multi-line comment starts with /* and ends with */.
  • Any information between /* and */ will be ignored by the compiler.

An example of how we use a multi-line comment:

        
#include <stdio.h>

int main() {
    /* This is a
    multi-line
    comment */
    printf("Hello World!");
    return 0;
}
        
    

Cookies Consent

This website uses cookies to ensure you get the best experience on our website.

Cookies Policy

We employ the use of cookies. By accessing BYTEFOXD9, you agreed to use cookies in agreement with the BYTEFOXD9's Privacy Policy.

Most interactive websites use cookies to let us retrieve the user’s details for each visit. Cookies are used by our website to enable the functionality of certain areas to make it easier for people visiting our website. Some of our affiliate/advertising partners may also use cookies.