Programming in C - I/O Operations

21. The following program
main()
{
int i = 2;
{ int i = 4, j = 5;
printf ("%d%d", i, j );
}
printf("%d%d", i, j );
}

  • Option : A
  • Explanation :
    This will not compile successfully. The scope of the variable ' j ' is the single printf statement that follows it.
    So. the last statement that involves ' j ' will complain about the undeclared identifier ' j '
Cancel reply
Cancel reply

23. main( )
   (
   int a = 5, b = 2;
   printf("%d", a+++b);
   }

  • Option : B
  • Explanation :
    The compiler will tokenize a + + + b as a, + +, b. So, a + + b is equivalent to a + + + b, which evaluates to 7
Cancel reply
Cancel reply