In C, what happens when an identifier declared in...
Guiding State PSC aspirants since 2016 50,000+ students · 1,000+ final selections Exam Calendar Results Call 9116926003
pscnotes
Pick your state
GPSC Prelims previous year questions

In C, what happens when an identifier declared in an inner block has the same name as an identifier declared in an enclosing block?

Asked in GPSC ICT Officer, Class-2 2026

  1. The inner declaration always generates a compilation error.
  2. The inner identifier is automatically elevated to global scope.
  3. The inner declaration shadows the outer identifier, making the outer identifier inaccessible by its unqualified name within the inner block.
  4. The inner declaration automatically changes the value stored in the outer identifier.
Show answer

Answer: C. The inner declaration shadows the outer identifier, making the outer identifier inaccessible by its unqualified name within the inner block.

This previous-year question came without the commission's answer key; the answer was checked by AI. Always confirm with the official key.

More GPSC Prelims previous year questions questions

All 18,593 GPSC Prelims previous year questions questions →