Question:

Consider the following ANSI C program: 

int main() { 
    Integer x; 
    return 0; 
}

Which one of the following phases in a seven-phase C compiler will throw an error?

Show Hint

Identifiers may pass lexical and syntax checks but still fail semantic analysis if their meanings are invalid in the language.
Updated On: Dec 30, 2025
  • Lexical analyzer
  • Syntax analyzer
  • Semantic analyzer
  • Machine dependent optimizer
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation

Step 1: Lexical analysis.
The token \texttt{Integer} is a valid identifier in C, so the lexical analyzer will not flag any error.

Step 2: Syntax analysis.
The statement \texttt{Integer x;} follows the syntactic form of a declaration, so the syntax analyzer accepts it.

Step 3: Semantic analysis.
In ANSI C, \texttt{Integer} is not a predefined type (unlike \texttt{int}). Since \texttt{Integer} has not been declared as a type using \texttt{typedef}, this results in a semantic error (undeclared type identifier).

Step 4: Conclusion.
Therefore, the error is detected during semantic analysis.

Final Answer: (C)

Was this answer helpful?
0
0

Top Questions on Parsing