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 above — ConceptC++ statements are commonly terminated by a semicolon ;. A missing terminator requires a diagnostic, but the C++ language does not standardize the…
- A.
Semicolon missing
- B.
Statement missing
- C.
Error in statements
- D.
More than one of the above
- 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
Consider
std::cout << "Hello"followed byreturn 0;on the next line, with no semicolon after the output statement.The parser continues from the output expression and encounters
returnwhere it expected the;terminator.GCC can emit
expected ';' before 'return', while MSVC can reportsyntax 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.