Multiple choice

Find out the output of the given program or error if any.

static int i=10;
int main()
{     
i=25;       // line 4     
printf(%d,i);     
return 0;
}

  1. 10

  2. 25

  3. Garbage value

  4. Error in the program

  5. None of these

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

This is the correct option because the scope of static variable is throughout the program, hence the assignment at line 4 changes the value of static variable to 25. So this is the correct answer.