C Language MCQ’S | Control Instructions 2

6.
What will be the output of the program?

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

7.
What will be the output of the program?

#include<stdio.h>
int main()
{
char str[]=”C-program”;
int a = 5;
printf(a >10?”Ps\n”:”%s\n”, str);
return 0;
}

A. C-program
B. Ps
C. Error
D. None of above

8.
What will be the output of the program?

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

A. b = 300 c = 200
B. b = 100 c = garbage
C. b = 300 c = garbage
D. b = 100 c = 200

9.
What will be the output of the program?

#include<stdio.h>
int main()
{
unsigned int i = 65535; /* Assume 2 byte integer*/
while(i++ != 0)
printf(“%d”,++i);
printf(“\n”);
return 0;
}

A. Infinite loop
B. 0 1 2 … 65535
C. 0 1 2 … 32767 – 32766 -32765 -1 0
D. No output

10.
What will be the output of the program?

#include<stdio.h>
int main()
{
int x = 3;
float y = 3.0;
if(x == y)
printf(“x and y are equal”);
else
printf(“x and y are not equal”);
return 0;
}
A. x and y are equal
B. x and y are not equal
C. Unpredictable
D. No output

 

Visitor Counter

0056755