Consider Line 3 of the following C program: int main() { /* Line 1 */ int I,…
2005
Consider Line 3 of the following C program:
int main() { /* Line 1 */
int I, N; /* Line 2 */
fro (I = 0, I < N, I++); /* Line 3 */
}Identify the compiler's response about Line 3 while creating the object module.
- A.
Both lexical and syntactic errors
- B.
Only a lexical error
- C.
Only syntactic errors
- D.
No compilation error
Attempted by 123 students.
Show answer & explanation
Correct answer: C
Correct answer: Only syntactic errors
Lexical analysis:
frois a valid identifier token, and the symbols such as(,,,++, and)are valid tokens. So this is not a lexical error.Intended syntax analysis: In this compiler-design/PYQ framing, the line is treated as a malformed
forstatement:frois not theforkeyword, and the loop header uses commas where semicolons are expected. Hence the intended compiler response is syntax errors.Clarification: Some C-language discussions treat
fro(...)as a possible function-call expression in an older C dialect. That is a different interpretation from the intended answer key for this item.