Multiple choice

Consider the below given code: main() {
int i=0; //line 1
clrscr();
printf(%d,i); i++;
if(i!=10)
main(); getch(); } The above code snippet will run in an infinite loop. What resolution shall be applied in order to terminate the loop as well?

  1. int static i=0;

  2. const int i=0;

  3. declaring variable i as global

  4. static int i=0;

  5. none of these

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

A static variable sustains its value until the program execution.