C Language MCQ’S | Control Instructions 5

21.
What will be the output of the program?

#include<stdio.h>
int main()
{
int x = 10, y = 20;
if(!(!x) && x)
printf(“x = %d\n”, x);
else
printf(“y = %d\n”, y);
return 0;
}

A. y =20
B. x = 0
C. x = 10
D. x = 1

22.
What will be the output of the program?

#include<stdio.h>
int main()
{
int i=4;
switch(i)
{
default:
printf(“This is default\n”);
case 1:
printf(“This is case 1\n”);
break;
case 2:
printf(“This is case 2\n”);
break;
case 3:
printf(“This is case 3\n”);
}
return 0;
}

A. This is default
This is case 1
B. This is case 3
This is default
C. This is case 1
This is case 3
D. This is default

23.
What will be the output of the program?

#include<stdio.h>
int main()
{
int i = 1;
switch(i)
{
printf(“Hello\n”);
case 1:
printf(“Hi\n”);
break;
case 2:
printf(“\nBye\n”);
break;
}
return 0;
}

A. Hello
Hi
B. Hello
Bye
C. Hi
D. Bye

 

24.
What will be the output of the program?

#include<stdio.h>
int main()
{
char j=1;
while(j < 5)
{
printf(“%d, “, j);
j = j+1;
}
printf(“\n”);
return 0;
}

A. 1 2 3 … 127
B. 1 2 3 … 255
C. 1 2 3 … 127 128 0 1 2 3 … infinite times
D. 1, 2, 3, 4

25.
What will be the output of the program?

#include<stdio.h>
int main()
{
int x, y, z;
x=y=z=1;
z = ++x || ++y && ++z;
printf(“x=%d, y=%d, z=%d\n”, x, y, z);
return 0;
}

A. x=2, y=1, z=1
B. x=2, y=2, z=1
C. x=2, y=2, z=2
D. x=1, y=2, z=1