ExamVeda
Login
Home
Operators and Expressions
?

What is the output of the following statements?
int b=15, c=5, d=8, e=8, a;
a = b>c ? c>d ? 12 : d>e ? 13 : 14 : 15;
printf("%d", a);

Answer & Solution
Correct Answer: Option B
Expression
a = b>c ? c>d ? 12 : d>e ? 13 : 14 : 15;
can be rewritten as
if(b>c)
{
   if(c>d)
      a = 12;
   else
   {
      if(d>e)
         a = 13;
      else
         a = 14;
   }
}
else
{
   a = 15;
}
Examveda
Question posted by Examveda
Community

Join the Discussion

2 Comments
Shailendra Raghuvanshi
Shailendra Raghuvanshi 10 years ago

Superb
Riti Thakur
Riti Thakur 11 years ago
best