[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

C Programming :: Declarations and Initializations - Discussion

Home > C Programming > Declarations and Initializations > MCQs Questions Discussion

13 / 54

What is the output of the following program ?

#include <stdio.h>
void main()
{
printf("%d",10?0?5:1:12);
}

A10

B0

C12

D1

Answer: Option (Login/Signup)

Show Explanation

            (Test condition) ?  value_if_true : value_if_false

Line no. 3 i.e, 10?(0?5:1):12 simply means if 10 is true then return (0?5:1) else return 12.

Again, (0?5:1) simply means if 0 is true then return 5 else return 1.

So here, 10 is true so the result is (0?5:1), and here 0 is false, which gives 1 as the output, hence the correct option is option D.

Asked In ::

Post Your Answer Here:     

Reply    
Rate This: +1 -2 +
    Report


Report Error

Please Login First Click Here

Reply    
Rate This: +0 -0
    Report


Report Error

Please Login First Click Here