Skip to content
GATEiit

GATE CSE 2021 Set 2 Q13: Compiler phase that reports an error for 'Integer x;'

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?

Try it: multiple choice: exactly one correct option

Select one option
Wrong answer costs 1/3 mark in GATE.
Show answer and explanation

Answer: C (official GATE 2021 final answer key)

Concept used: An undeclared type name is a valid identifier token; the error is about meaning (an unknown type), which is checked using the symbol table.

First step: Check each phase in turn: "Integer" is a legal identifier token, and "identifier identifier ;" can be parsed; what is wrong is that Integer is not a declared type.

Full step-by-step solution

Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.

Share this question

WhatsAppDownload image

Source: official GATE 2021 Set 2 CS question paper and final answer key, organised by IIT Bombay. Question paper · Answer key