How to Add Multi-line Comments in C

What is comment in C?

In C, a comment is a piece of text in code that is not executed when the program is executed.

Comments are used to provide explanations, and keep documentation, or notes within the code for future reference and code understanding.

C supports two types of comments: single-line comments and multi-line comments.

Lines between /* and */ is treated as multi-line comments by C compiler.

Adding multi-line comments in C

To create a multi-line comment, add /* to begin a multi-line comment and */ to end it.

In the following example, the multiple lines

        This is an example 
        of multiple lines 
        comment in C
is placed between /* and */. It creates a multi-line comment. C compiler will ignore the lines as comment and it will not have any effect on the execution of the program.

Example of C Multi-line Comments


Output of the above example

Use /* to begin a multiple lines comment and */ to end it.

The output does not contain the commented lines.

Live Code Playground

In the following C code editor, you can practice the above code by adding more multi-line comments. Click the 'Execute Code' button to execute the code; the executed output will be displayed in the following C Code Output frame. Practice until you become comfortable and proficient with your code.

C logo C Online Editor
C Code Output