What symbol is used for a single-line comment in C++?

Prepare for the ASU CSE100 Programming Exam with C++ Study Guide. Review flashcards, multiple choice questions, with hints and explanations. Master your exam!

In C++, a single-line comment is denoted by the use of two forward slashes, represented as "//". This tells the compiler to ignore everything on that line after the slashes. Using single-line comments is a practical way for programmers to annotate their code, making it easier to understand without affecting the execution of the program.

The other options represent different forms of commenting or other concepts in programming. For instance, /* ... / is used for multi-line comments, where anything between the / and */ is commented out, allowing for several lines to be commented at once. The # symbol is often used for preprocessor directives in C and C++, not for comments. Lastly, ** is not a recognized comment syntax in C++.

Thus, the correct symbol for a single-line comment in C++ is indeed "//", as it efficiently comments out a line or a portion of a line of code.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy