×

Advanced Coding & Software Engineering Program

Duration: 1 Year (12 Months)

Join our premium 1-year program to master cutting-edge technologies and become an industry-ready Software Engineer!

Course Coverage

  • Languages: C, C++, Java, JavaScript, Python
  • Web Technologies: HTML, CSS, Bootstrap 5, MERN Stack, Full Stack Development
  • Databases: MySQL, MongoDB
  • Data Science Libraries: Pandas, NumPy
  • Development Tools: Visual Studio Code, IntelliJ IDEA, PyCharm, Postman, Git, GitHub
  • Cloud Platforms: Vercel, MongoDB Atlas

Program Highlights

  • Live Classes: Interactive sessions with real-time doubt resolution
  • Hands-On Sessions: Practical coding exercises to build real-world skills
  • Industry Experts: Learn from professionals with years of experience
  • Live Project: Work on real-world projects to apply your skills
  • Get Certificate: Earn a professional certificate upon program completion

Course Fee: Only ₹1020 / month
Limited Period Offer!

Comments in c language



Last Updated on: 3rd Jul 2025 15:44:20 PM

Comments in C are used to explain the code, make it more readable, and temporarily disable code during testing or debugging. Comments are ignored by the compiler, so they do not affect the execution of the program.

 

1. Why Use Comments?

  • To describe the purpose of code sections.

  • To improve code readability for yourself or other programmers.

  • To debug code by disabling specific lines temporarily.

  • To leave notes or reminders for future updates.

 

2. Types of Comments in C

C supports two types of comments:

 

a. Single-Line Comments

Starts with // and continues to the end of the line.

 

Syntax:

// This is a single-line comment

 

Example:

#include <stdio.h>

int main() {
    int x = 10;  // Declare a variable
    printf("%d", x);  // Print the value
    return 0;
}

 

Explanation:

  • Everything after // on that line is ignored by the compiler.

 

b. Multi-Line Comments

Starts with /* and ends with */. It can span across multiple lines.

 

Syntax:

/* 
   This is a multi-line comment
   that can stretch over several lines
*/

 

Example:

#include <stdio.h>

int main() {
    /* This program prints a number
       stored in a variable */
    int num = 25;
    printf("%d", num);
    return 0;
}

 

Explanation:

  • Useful for longer explanations or commenting out blocks of code.

 

3. Using Comments to Disable Code

You can use comments to temporarily remove code from execution without deleting it.

 

Example:

#include <stdio.h>

int main() {
    int x = 5;
    // x = x + 10;  // Temporarily disabled for testing
    printf("%d", x);
    return 0;
}

 

Best Practices for Writing Comments :

 

  • Use comments to explain “why”, not just “what”.

  • Keep comments short and meaningful.

  • Avoid over-commenting obvious code (e.g., i++; // increment i).

  • Update or remove outdated comments during code changes.

 


Online - Chat Now
Let’s Connect

Inquiry Sent!

Your message has been successfully sent. We'll get back to you soon!

iKeySkills Logo