C - Control Flow Constructions Questions and Answers
Practice ModeShowing 10 of 62 questions
Q51
int a = 0, b = 2;
if ( a = 0) b = 0;
else b *=10;
what is the value of b?
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;
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");
}
Answer: Option C
Q54
How many x are printed ?
for ( i = 0, j = 10; i < j; i++, j-- --)
printf ("x");
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);
}
Answer: Option A
Q56
unsigned char c;
for ( c = 0; c! = 256; c + 2)
printf ("%d", c);
How many times the loop is executed ?
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);
Answer: Option A
Q58
What is output of the following code ?
main ( )
{
int i = 3;
while ( i - - )
{
int i = 100;
i - - ;
printf ("%d. . " , i );
}
}
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) ;
}
}
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 ?
Answer: Option C