C Language MCQ’S | Control Instructions 4

16.
What will be the output of the program?

#include<stdio.h>
int main()
{
int k, num = 30;
k = (num < 10) ? 100 : 200;
printf(“%d\n”, num);
return 0;
}

A. 200
B. 30
C. 100
D. 500

17.
What will be the output of the program?

#include<stdio.h>
int main()
{
int a = 300, b, c;
if(a >= 400)
b = 300;
c = 200;
printf(“%d, %d, %d\n”, a, b, c);
return 0;
}

A. 300, 300, 200
B. Garbage, 300, 200
C. 300, Garbage, 200
D. 300, 300, Garbage

18.
What will be the output of the program?

#include<stdio.h>
int main()
{
int x=1, y=1;
for(; y; printf(“%d %d\n”, x, y))
{
y = x++ <= 5;
}
printf(“\n”);
return 0;
}
A. 2 1
3 1
4 1
5 1
6 1
7 0
B. 2 1
3 1
4 1
5 1
6 1
C. 2 1
3 1
4 1
5 1
D. 2 2
3 3
4 4
5 5

19.
What will be the output of the program?

#include<stdio.h>
int main()
{
int i = 5;
while(i– >= 0)
printf(“%d,”, i);
i = 5;
printf(“\n”);
while(i– >= 0)
printf(“%i,”, i);
while(i– >= 0)
printf(“%d,”, i);
return 0;
}
A.
4, 3, 2, 1, 0, -1
4, 3, 2, 1, 0, -1

B.
5, 4, 3, 2, 1, 0
5, 4, 3, 2, 1, 0

C.
Error

D.
5, 4, 3, 2, 1, 0
5, 4, 3, 2, 1, 0
5, 4, 3, 2, 1, 0

20.
What will be the output of the program?

#include<stdio.h>
int main()
{
int i=3;
switch(i)
{
case 1:
printf(“Hello\n”);
case 2:
printf(“Hi\n”);
case 3:
continue;
default:
printf(“Bye\n”);
}
return 0;
}
A. Error: Misplaced continue
B. Bye
C. No output
D. Hello Hi

Visitor Counter

0051052