int main() {
int x
x = (1 + 2;
return x;
}Which of the following statements is true with respect to this source code in C language ?
MH SET - 2025, SET Exam - 2025,
Answer: A
The code has a syntax error.
int x lacks the semicolon that ends a declaration, and x = (1 + 2; has an opening parenthesis with no closing one. Both break the grammar of C, so the compiler's parser rejects the program before it is ever linked or run.
A semantic error is grammatically valid code with a wrong meaning, such as a type mismatch. A linking error arises when a referenced function or variable cannot be found. A runtime error occurs while a compiled program runs. None can happen here because the code does not compile.
Please log in or register to report this question.