Which symbols can be used to create comments in C++?

Prepare for the C Certified Entry-Level Programmer Test using flashcards and multiple choice questions with detailed hints and explanations. Sharpen your programming skills and succeed in your certification exam!

In C++, comments are used to make notes in the code that are ignored by the compiler. There are two primary ways to create comments:

  1. Single-line comments are initiated with two forward slashes, //. Everything following these slashes on that line is treated as a comment.
  1. Multi-line comments are enclosed between /* and */. This allows for comments to span multiple lines and all text between these symbols will be ignored by the compiler.

The correct answer highlights the symbols // for single-line comments and /* for the start of multi-line comments, indicating that both comment types are valid in C++. Understanding how to effectively use comments is crucial for writing readable code, as they help document what the code is intended to do, making it easier for others (or oneself) to understand the logic later on.

The other options present symbols that are not valid for comments in C++. For instance, ## is not recognized in C++ as a comment marker, and neither are -- and #, which have different meanings in C++. Therefore, the presence of // and /* in the correct answer makes it the only viable choice for representing comments in C++.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy