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

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


22. printf("ab", "cd", "ef");
prints

Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


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

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


24. A possible output of the following program fragment
  static char wer [ ] [5] = { "harmot", "merli", "axari" };
  printf({"%d%d%d", wer, wer[0], &wer[0][0]);
is

Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


25. The following program
main( )
{
printf ("%u", main);
}
results in

  • Option : C
  • Explanation :
    Like array name, name of a function is a pointer to it.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *