B.Tech Students: Apply for Live Programming Internship C, C++, Java, Python ,Web page Designing, PHP C++ Comments Guide | TutorialsApp

C++ Comments Guide

What Are Comments in C++?

Comments are notes in your code ignored by the compiler. They're useful for explaining code, making it easier to understand.

Comments आपके कोड में नोट्स होते हैं जिन्हें compiler इग्नोर करता है। यह कोड को समझने में आसान बनाते हैं।

Types of Comments

  • Single-line: Starts with // and runs to the end of the line.
  • Multi-line: Starts with /* and ends with */.
  • Single-line: // से शुरू होकर लाइन के अंत तक चलता है।
  • Multi-line: /* से शुरू और */ पर खत्म होता है।

Example: C++ Program with Comments

#include <iostream>
using namespace std;

int main() {
    // This is a single-line comment
    cout << "Hello, World!" << endl;

    /* This is a
       multi-line comment
       explaining the next line */
    cout << "Welcome to C++ Comments Guide!" << endl;

    return 0;
}

In this example, // adds single-line comments, and /* ... */ adds multi-line comments to explain the code.

इस उदाहरण में, // single-line comment जोड़ता है और /* ... */ multi-line comment जोड़कर कोड को समझाता है।