If a semicolon is not used at the end of the statement, what message will be…

2023

If a semicolon is not used at the end of the statement, what message will be displayed by C++?

Answer: E. None of the aboveConceptC++ statements are commonly terminated by a semicolon ;. A missing terminator requires a diagnostic, but the C++ language does not standardize the…

  1. A.

    Semicolon missing

  2. B.

    Statement missing

  3. C.

    Error in statements

  4. D.

    More than one of the above

  5. E.

    None of the above

Attempted by 469 students.

Show answer & explanation

Correct answer: E

Concept

C++ statements are commonly terminated by a semicolon ;. A missing terminator requires a diagnostic, but the C++ language does not standardize the exact wording; each compiler reports the parser condition in its own form.

Application

  1. Consider std::cout << "Hello" followed by return 0; on the next line, with no semicolon after the output statement.

  2. The parser continues from the output expression and encounters return where it expected the ; terminator.

  3. GCC can emit expected ';' before 'return', while MSVC can report syntax error: missing ';' before '}'. These examples show compiler-specific diagnostic strings for a missing semicolon.

Cross-check

Adding ; removes the syntax diagnostic, confirming the underlying omission. The compiler messages shown above are not identical to the listed phrases Semicolon missing, Statement missing, Error in statements, or More than one of the above.

Result

The official BPSC final answer key marks “None of the above” for this source question, consistent with the implementation-dependent diagnostic wording.

Explore the full course: Bpsc

Loading lesson…