0 votes 0 votes What is the output of the following C program? #include<stdio.h> #define SQR(x) (x*x) int main() { int a; int b=4; a=SQR(b+2); printf("%d\n",a); return 0; } 14 36 18 20 Programming in C programming-in-c + – Lakshman Bhaiya asked Mar 2, 2018 edited Mar 11, 2018 by Sukanya Das Lakshman Bhaiya 404 views answer comment Share Follow See all 4 Comments See all 4 4 Comments reply Lakshman Bhaiya commented Mar 2, 2018 reply Follow Share My answer is 36, it is correct or not? 0 votes 0 votes akb1115 commented Mar 2, 2018 reply Follow Share 14 is the answer because it will be evaluated as:- b+2*b+2=4+2*4+2=4+8+2=14 2 votes 2 votes gari commented Mar 2, 2018 reply Follow Share Answer is 14 . # define is a macro definition . It replaces SQR(b+2) with (b+2*b+2).So a is computed as 14. Note the placing of the brackets. 0 votes 0 votes akash.dinkar12 commented Mar 2, 2018 reply Follow Share a=b+2*b+2 =4+2*4+2 =4+8+2 = 14... 1 votes 1 votes Please log in or register to add a comment.
2 votes 2 votes As it is given (x*x) : The result will be b+2*b+2 which means: 4+2*4+2 = 14 Had it be ((x)*(x)): The answer would have been ((b+2)*(b+2)) = 36 Subham Nagar answered Mar 2, 2018 Subham Nagar comment Share Follow See all 0 reply Please log in or register to add a comment.