Tuesday 30 December 2014

Programming Quiz-39

Q: What will be the output of following program?

#include<stdio.h>
void main( )
{
      int i=3;
      while ( i>0)
      {
             int i=3;
             printf("%d\n",i);
             i--;
       }
}

Options:
1. Program will fail to compile because variable is duplicated.
2. Program will fail to compile because variables can only be declared in the beginning of the program.
3. Program will compile and execute successfully and will print 3, 2, 1 on different lines.
4. Program will enter into infinite loop

Answer: 4

No comments:

Post a Comment