C Preprocessor - Find Output of Program :: Discussion


4.What will be the output of the program?
A.9, 4
B.27, 4
C.27, 6
D.Error
Answer:  Option  C
Explanation:

The macro function CUBE(x) (x*x*x) calculates the cubic value of given number(Eg: 103.)

Step 1int a, b=3; The variable a and b are declared as an integer type and varaible b id initialized to 3.

Step 2a = CUBE(b++); becomes

=> a = b++ * b++ * b++;

=> a = 3 * 3 * 3; Here we are using post-increement operator, so the 3 is not incremented in this statement.

=> a = 27; Here, 27 is store in the variable a. By the way, the value of variable b is incremented by 3. (ie: b=6)

Step 3printf("%d, %d\n", a, b); It prints the value of variable a and b.

Hence the output of the program is 27, 6.

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