C Preprocessor - Find Output of Program :: Discussion


6.What will be the output of the program?
A.a = 10, b = 12
B.a = 12, b = 10
C.Error: Undefined symbol 't'
D.Error: Declaration not allowed in macro
Answer:  Option  B
Explanation:

The macro SWAP(a, b) int t; t=a, a=b, b=t; swaps the value of the given two variable.

Step 1int a=10, b=12; The variable a and b are declared as an integer type and initialized to 10, 12 respectively.

Step 2SWAP(a, b);. Here the macro is substituted and it swaps the value to variable a and b.

Hence the output of the program is 12, 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