Skip to content
Related Articles

Related Articles

C | Variable Declaration and Scope | Question 5
  • Difficulty Level : Basic
  • Last Updated : 09 Aug, 2019

Output?




int main()
{
  {
      int var = 10;
  }
  {
      printf("%d", var);  
  }
  return 0;
}

(A) 10
(B) Compiler Error
(C) Garbage Value


Answer: (B)

Explanation: x is not accessible.

The curly brackets define a block of scope. Anything declared between curly brackets goes out of scope after the closing bracket.

Quiz of this Question

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :