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++?
- A.
Semicolon missing
- B.
Statement missing
- C.
Error in statements
- D.
More than one of the above
- E.
None of the above
Attempted by 235 students.
Show answer & explanation
Correct answer: A
In C++, a semicolon (;) is used to terminate a statement. If a semicolon is missing at the end of a statement, the compiler will generate a syntax error during compilation. The error message will typically indicate that a semicolon is expected or missing. This is because the compiler relies on semicolons to determine where one statement ends and another begins. Without it, the code is not valid, and the compiler cannot proceed. Therefore, the correct response is related to a syntax error due to the missing semicolon.
हिन्दी उत्तर: C++ में सेमीकोलन (;) कथन को समाप्त करने के लिए प्रयोग किया जाता है। यदि कथन के अंत में सेमीकोलन नहीं होता है, तो कंपाइलर संकेत-त्रुटि (syntax error) उत्पन्न करेगा। त्रुटि संदेश आमतौर पर यह इंगित करेगा कि सेमीकोलन अपेक्षित है या अनुपस्थित है। यह इसलिए है क्योंकि कंपाइलर सेमीकोलन के आधार पर यह निर्धारित करता है कि एक कथन कहाँ समाप्त होता है और दूसरा कहाँ शुरू होता है। इसके बिना, कोड वैध नहीं होता है और कंपाइलर आगे नहीं बढ़ सकता है। इसलिए, सही उत्तर सेमीकोलन की अनुपस्थिति के कारण सिंटैक्स त्रुटि से संबंधित होना चाहिए।