c++ single comment

// This is a single-line comment in C++. It begins with // and extends to the end of the line.

int main() {
    // This is a comment within a function.
    // It provides a brief explanation of the purpose of the code that follows.

    int x = 5; // This comment explains the initialization of the variable 'x' with the value 5.
    int y = 10; // Similarly, this comment explains the initialization of the variable 'y' with the value 10.

    // The following line calculates the sum of x and y.
    int sum = x + y;

    return 0; // Indicates the successful execution of the program.
}