Control Structure Questions and Answers
Practice ModeShowing 10 of 97 questions
Q11
Find the output
void main ( )
char x='A';
switch (x)
{
if (x==A)
{
printf("tomtom");
}
else
{
printf("tom")
default:printf("harry");
}
}
}
Answer: Option D
Q12
Find the output
void main ( )
{
if (printf("hello");
else
printf ("hai");
}
Answer: Option A
Q13
Find the output
void main ( )
{
switch (2)
{
case 2:
printf("no");
continue;
case 1:
printf("output");
default :
printf ("continue");
}
Answer: Option D
Q14
Which of the following is/are true for nested if
I. It can only test for equality.
II. Conditions may be repeatred for number of times.
III. it can evaluate relational or logical expressions.
IV. Character constants are automatically converted to integers.
Answer: Option C
Q15
Find the output.
void main ( )
{
int i=2;
i++;
if (i=4)
printf("i=4");
else
printf("i=3");
}
Answer: Option B
Q16
Find the output
void main ( )
{
int x, y;
printf("%d", x=(y=5, y*y));
}
Answer: Option B
Q17
Find the output
void main ( )
{
char a='H';
switch (a)
{
case 'H':
printf("%c", 'H');
case 'E":
printf("%c", 'E');
case 'L':
printf("%c", 'L')}
case 'O':
printf ("%c", 'O');
}
}
Answer: Option D
Q18
Which of the following is true about the switch statement ?
Answer: Option D
Q19
Find the output
void main ( )
{
int x=1, y=2, z=3, result;
result=(x+1?y>=2?z>3?1:2:3:4);
printf("%d",result);
}
Answer: Option B
Q20
Find the output
void main ( )
{
it (6>3)
{
printf("hello");
break;
}
else
printf("bye");
}
Answer: Option C