Warning: implode(): Invalid arguments passed in /www/wwwroot/jobquiz.info/mdiscuss.php on line 336 What will be the output of the program? #include<stdio.h> #define SQR(x)(xx) int main() { int a, b=3; a = SQR(b+2); printf("%d\n", a); return 0; } ?->(Show Answer!)
1. What will be the output of the program? #include<stdio.h> #define SQR(x)(xx) int main() { int a, b=3; a = SQR(b+2); printf("%d\n", a); return 0; }
Ask Your Doubts Here
Comments
By: guest on 01 Jun 2017 06.00 pm
The macro function SQR(x)(x*x) calculate the square of the given number 'x'. (Eg: 102) Step 1: int a, b=3; Here the variable a, b are declared as an integer type and the variable b is initialized to 3. Step 2: a = 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 3: printf("%d\n", a); It prints the value of variable 'a'. Hence the output of the program is 11