C Programming/C Basics

C Comments

Updated on January 8, 2026
1 min read

C Programming Comments

Comments in C are used to explain code.

They are ignored by the compiler, which means they do not affect program execution.

Comments make programs:

  • Easy to understand
  • Easy to read
  • Easy to maintain

Why Comments Are Used

  • To explain what the code does
  • To make code readable for others
  • To remember logic when revisiting code
  • To temporarily disable code during testing

Types of Comments in C

C supports two types of comments:

  1. Single-line comment
  2. Multi-line comment

1. Single-Line Comment

single-line comment starts with //

 Everything after // on that line is treated as a comment.

Syntax

// This is a single-line comment

Example

int age = 20;   // storing age

Here:

// storing age is ignored by the compiler

2. Multi-Line Comment

multi-line comment starts with /* and ends with */

 It can span across multiple lines.

Syntax

/* This is a
   multi-line comment */

Example

/* This program
   prints Hello World */
printf("Hello World");

Commenting Out Code (Very Common Use)

Comments are often used to disable code temporarily.

// printf("This line will not execute");

or

/*
printf("Line 1");
printf("Line 2");
*/

Important Rules About Comments

  • Comments are not executed
  • Nested comments are not allowed
  • Comments cannot be used inside strings

Wrong:

printf("Hello // world");

Difference Between Single-Line and Multi-Line Comments

FeatureSingle-LineMulti-Line
Symbol///* */
LinesOne line onlyMultiple lines
UsageShort explanationDetailed explanation

One-Line Exam Answer

Comments in C are used to explain the code and are ignored by the compiler during program execution.

C Comments | C Programming | Learn Syntax