C Language MCQ’S | Control Instructions 12

56.
What is the output of this C code?

int main()
{
int a = 2;
int b = 0;
int y = (b == 0) ? a :(a > b) ? (b = 1): a;
printf(“%d\n”, y);
}

A. Compile time error
B. 1
C. 2
D. Undefined behaviour


 

57.
What is the output of this C code?

int main()
{
int y = 1, x = 0;
int l = (y++, x++) ? y : x;
printf(“%d\n”, l);
}
A. 1
B. 2
C. Compile time error
D. Undefined behaviour

 

58.
What is the output of this C code?

void main()
{
int k = 8;
int m = 7;
int z = k < m ? k++ : m++;
printf(“%d”, z);
}
A. 7
B. 8
C. Run time error
D. None of the mentioned.

 

59.
Comment on the output of this C code?

void main()
{
int k = 8;
int m = 7;
int z = k < m ? k = m : m++;
printf(“%d”, z);
}

A. Run time error
B. 7
C. 8
D. Depends on compiler

 

60.
The code snippet below produces

void main()
{
1 < 2 ? return 1 : return 2;
}

A. returns 1
B. returns 2
C. varies
D. Compile time error

 

Visitor Counter

0056716