Programming in C - Decision Making and Looping

31. The switch feature

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 *


32. Break statement can be simulated by using

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 *


33. The following program fragment

if (2 < 1)
;
else
x = (2 < 0) ? printf("one") : printf("four");
printf ("%d", x);

  • Option : D
  • Explanation :
    here else clause will be executed . Since 2 < 0 is false , 4 will be printed
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 *


34. Consider the following program fragment
if (a>b)
  printf("a>b");
else
  printf("else part");
  printf("a<=b");
a<=b will be printed if

  • Option : D
  • Explanation :
    The else clause has no brackets i.e., { and }. This means the else clause is made up of only one statement.
    So, printf(" a < = b") will be executed anyway, i.e. if a > b or a <= b. Hence the answer.
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 *


35. The body of the following for loop
  for( putchar( 'a' ); putchar (0); putchar (' c ') ) putchar ( 'b') ;
will be executed

  • Option : A
  • Explanation :
    The condition is putchar (0). This returns a value 0 which is a false condition.
    So, the loop will not be executed even once.
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 *