Multiple choice

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

int main()
{         
register int n;        
int i;         
printf(Enter the no. of loops to run:);         
scanf(%d,&n);         
for (i=0;i < n;i++)         
{                 
printf(%d\\n,i);         
}
}

  1. Prints 1 to n

  2. Prints 1 to n-1

  3. Prints n

  4. Infinite loop

  5. Compilation error

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

error: address of register variable ‘n’ requested The program will not print any output because there is an error in the program. We cannot refer to the address of a register variable because it is not stored in the memory but on the registers inside the CPU. Only variable stores in the memory have an address.S o there will be an error in the program. Hence this option is correct.