Which of the following is an example of a valid C++ comment?

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

A valid C++ comment uses the syntax that the C++ language recognizes for comments. In C++, comments can be written in two primary ways: as single-line comments initiated with // or as multi-line comments enclosed within /* and */.

The option that states "/* This is a comment */" is correctly formatted as a multi-line comment in C++. This allows for the inclusion of comments that span multiple lines without interfering with the code.

The other options do not conform to the C++ commenting syntax. Option B and D use --, which is not a valid comment indicator in C++. Option C uses #, which may be recognized in some other programming languages, like Python or shell scripting, but it does not function as a comment in C++. Therefore, the multi-line comment format shown in the first option is the only correct representation of a comment in C++.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy