C - Control Flow Constructions Questions and Answers

Practice Mode
Showing 10 of 62 questions
Q51
 int a = 0, b = 2; if ( a = 0) b = 0; else b *=10; what is the value of b?
  • A 0
  • B 20
  • C 2
  • D none
Answer: Option B
Q52
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;
  • A 0
  • B 2
  • C 1
  • D none
Answer: Option A
Q53
 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"); }
  • A pass pass2
  • B pass 1 Fail2
  • C Fail pass2
  • D Fail Fail 2
Answer: Option C
Q54
 How many x are printed ? for ( i = 0, j = 10; i < j; i++, j-- --) printf ("x");
  • A 10
  • B 5
  • C 4
  • D none
Answer: Option B
Q55
 What is the output of the following program ? main ( )    {     unsigned int i;     for (i = 10; i >=0; i- -)                     printf ("%d", i);    }
  • A prints numbers 10 to 0
  • B prints numbers 10 to 1
  • C prints numbers 10 to-1
  • D goes into infinite loop
Answer: Option A
Q56
unsigned char c; for ( c = 0; c! = 256; c + 2) printf ("%d", c); How many times the loop is executed ?
  • A 127
  • B 128
  • C 256
  • D infinitely
Answer: Option D
Q57
 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);
  • A 121
  • B 11
  • C 10
  • D none of the above
Answer: Option A
Q58
 What is output of the following code ? main ( )  {  int i = 3; while ( i - - )    {     int i = 100;     i - - ;    printf ("%d. . " , i ); } }
  • A Infinite loop
  • B Error
  • C 99..99..99..
  • D 3..2..1..
Answer: Option C
Q59
 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) ;      }   }
  • A ABCDEF
  • B EFG
  • C FG
  • D Error
Answer: Option C
Q60
 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 ? 
  • A 13
  • B 34
  • C 33
  • D 31
Answer: Option C
Questions and Answers for Competitive Exams Various Entrance Test