Discussion
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 ?
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.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development