C Preprocessor - Find Output of Program :: Discussion


13.What will be the output of the program?
A.5
B.9
C.10
D.3+7
Answer:  Option  C
Explanation:

The macro MAX(a, b, c) (a>b ? a>c ? a : c: b>c ? b : c) returns the biggest of given three numbers.

Step 1int x; The variable x is declared as an integer type.

Step 2x = MAX(3+2, 2+7, 3+7); becomes,

=> x = (3+2 >2+7 ? 3+2 > 3+7 ? 3+2 : 3+7: 2+7 > 3+7 ? 2+7 : 3+7)

=> x = (5 >9 ? (5 > 10 ? 5 : 10): (9 > 10 ? 9 : 10) )

=> x = (5 >9 ? (10): (10) )

=> x = 10

Step 3printf("%d\n", x); It prints the value of 'x'.

Hence the output of the program is "10".

Tutorial Link:
Published by:Michael Daani

Comments are not available

Post your comments here:

Optional

Date to Date Current Affairs 2022

PakMCQs.net

Quick Links

GAT Subject



   Computer Science    English Mcqs    Agriculture    

Engineering



   Computer Science    Civil Engineering    

Technical



   Networking    Electronics    Database    

Past Papers



   Model Papers    FPSC Papers