Interviews Questions, Algorithms, Aptitude, C Interview Program, C Theory Question, Aptitude Tricks, Test Series,

Saturday 26 June 2021

Interview Hack#29 Answer:

 The output of the following Code:

  1. 10 11 12 13 14
  2. 10 10 10 10 10
  3. 10
  4. 0 1 2 3 4 5
  5. Error

Answer:

2. 10 10 10 10 10

Explanation:

The default storage class of the local variable is auto. The scope of auto variables is blocked in which it has been declared. When program control goes out of the scope auto variables are dead. So variable I which has been declared inside for loop has scope within a loop and in each iteration, the variable is dead and re-initialized.

0 comments:

Post a Comment