C Preprocessor - Find Output of Program :: Discussion


2.What will be the output of the program?
A.25
B.11
C.Error
D.Garbage value
Answer:  Option  B
Explanation:

The macro function SQR(x)(x*x) calculate the square of the given number 'x'. (Eg: 102)

Step 1int a, b=3; Here the variable a, b are declared as an integer type and the variable b is initialized to 3.

Step 2a = SQR(b+2); becomes,

=> a = b+2 * b+2; Here SQR(x) is replaced by macro to x*x .

=> a = 3+2 * 3+2;

=> a = 3 + 6 + 2;

=> a = 11;

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

Hence the output of the program is 11

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