C Language MCQ’S | Control Instructions 11

51.
We want to test whether a value lies in the range 2 to 4 or 5 to 7. Can we do this using a switch?

A. Yes
B. No

 

52.
By default, the data type of a constant without a decimal point is int, whereas the one with a decimal point is a double.

A. Yes
B. No

53.
What is the output of this C code?

int main()
{
int x = 2, y = 0;
int z = (y++) ? y == 1 && x : 0;
printf(“%d\n”, z);
return 0;
}

A. 0
B. 1
C. Undefined behavior
D. Compile time error

 

54.
What is the output of this C code?

int main()
{
int x = 1;
int y = x == 1 ? getchar(): 2;
printf(“%d\n”, y);
}

A. Compile time error
B. Whatever character getchar function returns
C. Ascii value of character getchar function returns
D. 2

55.
What is the output of this C code?

int main()
{
int x = 1;
short int i = 2;
float f = 3;
if (sizeof((x == 2) ? f : i) == sizeof(float))
printf(“float\n”);
else if (sizeof((x == 2) ? f : i) == sizeof(short int))
printf(“short int\n”);
}

A. float
B. short int
C. Undefined behavior
D. Compile-time error

 

Visitor Counter

0142303