Difficulty: Easy
Correct Answer: //
Explanation:
Introduction / Context:
Comments are essential for documentation and maintainability. C++ supports two primary comment styles: single-line comments and block comments. Knowing the correct introductory tokens prevents syntax errors and ensures that annotations do not accidentally become part of the program logic.
Given Data / Assumptions:
Concept / Approach:
In C++, the token // begins a single-line comment. Everything from // to the end of that physical line is ignored by the compiler. C++ also supports block comments beginning with /* and ending with / for multi-line remarks. Symbols such as , &&, backslash, or at-sign have other syntactic meanings and do not introduce comments.
Step-by-Step Solution:
Identify the desired behavior: comment out the remainder of a single line.Recall that the correct token in C++ for single-line comments is //.Place // before the text to be ignored.Confirm that the compiler discards the trailing text and proceeds with parsing the next line.
Verification / Alternative check:
Create a minimal program that contains code, a // comment, and a statement on the next line. Observe that only the code outside comments is compiled. Replacing // with other tokens will either cause compilation errors or change program meaning (for example, && is a logical operator).
Why Other Options Are Wrong:
Common Pitfalls:
Accidentally nesting block comments with / and */ can cause unexpected uncommenting. Using // avoids nesting issues for single lines.
Final Answer:
//.
Discussion & Comments