C - Control Flow Constructions

C - Control Flow Constructions
51.  int a = 0, b = 2;
if ( a = 0) b = 0;
else b *=10;
what is the value of b?
  • 0
  • 20
  • 2
  • none
Show Answer
52. int x = 2, y = 2 , z = 1;
what is the value of x after the following statements ?
if (x = y%2) z +=10;
else z +=20;

  • 0
  • 2
  • 1
  • none
Show Answer
53.  What is the result?
  main ( )
          {
   char c =-64; int i =-32;
unsigned int u =-16;
if (c>i)
    {
        printf ("pass1");
       if (c>u) printf ("pass2");
       else printf ("Fail2");}
else printf ("Fail");
 if (i<u) printf ("pass2");
else printf ("Fail2");
}

  • pass pass2
  • pass 1 Fail2
  • Fail pass2
  • Fail Fail 2
Show Answer
54.  How many x are printed ?

for ( i = 0, j = 10; i < j; i++, j-- --)
printf ("x");

  • 10
  • 5
  • 4
  • none
Show Answer
55.  What is the output of the following program ?
main ( )
   {
    unsigned int i;
    for (i = 10; i >=0; i- -)
                    printf ("%d", i);
   }


  • prints numbers 10 to 0
  • prints numbers 10 to 1
  • prints numbers 10 to-1
  • goes into infinite loop
Show Answer
56. unsigned char c;
for ( c = 0; c! = 256; c + 2)
printf ("%d", c);
How many times the loop is executed ?

  • 127
  • 128
  • 256
  • infinitely
Show Answer
57.  For the following code how many times the printf ( ) function is executed ?
int  i , j ;
for ( i =0 ; i <=10; i++);
for ( j = 0; j<=10; j++);
      printf ( "i = %d, j = %d\n", i , j);
  • 121
  • 11
  • 10
  • none of the above
Show Answer
58.  What is output of the following code ?
main ( )
 {
 int i = 3;
while ( i - - )
   {
    int i = 100;
    i - - ;
   printf ("%d. . " , i );
}
}

  • Infinite loop
  • Error
  • 99..99..99..
  • 3..2..1..
Show Answer
59.  What will be the output of the following code ?
   {
          ch = 'A';
           while (ch<='F')
         {
           switch (ch)
          {
           case 'A' : case 'B': case 'C': case 'D' : ch ++; continue;
           case 'E" : case 'F' : ch ++;
       }
          putchar (ch) ;
     }
  }
  • ABCDEF
  • EFG
  • FG
  • Error
Show Answer
60.  main ( )
   {
     int , ones,twos, threes, others; int c;
    ones =twos = threes = others = 0 ;
    while ( ( c = getchar ( ) ) !_ '\n')
   {
    switch (c)
    {
case ' 1 ' : ++ ones;
case ' 2 ' : ++twos;
case '3' : ++ threes;
               break;
default : ++others;
               break;
}

}
printf  ( "%d%d", ones, others );
}
If the input is "lalblc" what is the output ? 
  • 13
  • 34
  • 33
  • 31
Show Answer
Questions and Answers for Competitive Exams Various Entrance Test