10 10 votes Consider the following statements #define hypotenuse (a, b) sqrt (a*a+b*b); The macro call hypotenuse(a+2,b+3); Finds the hypotenuse of a triangle with sides $a+2$ and $b+3$ Finds the square root of $(a+2)^2$ and $(b+3)^2$ Is invalid Find the square root of $3 *a+4*b+5$ Programming in C programming-in-c macros isro2015 + – Purple 11.6k views answer comment Share Follow Print See all 8 Comments 8 8 Comments reply Show 5 previous comments Divyanshum29 commented Aug 24, 2018 reply Follow flag after macro expansion it will become sqrt(a+2*a+2+b+3*b+3) we will check the priority order , we know that the priority of * is more than + so we solve it like {a+(2*a)+2+b+(3*b)+3} it will be equal to a+2a+2+b+3b+3= 3a+4b+5 Ans is D 2 2 replyShare txds commented Feb 27, 2019 reply Follow flag it's irrelevant to the answer but can someone confirm, option 1 and 2 look the same for me. 0 0 replyShare Nagasaikanmatha commented Apr 30, 2021 reply Follow flag hypotenuse(a,b) = sqrt(a*a+b*b) hypotenuse(a+2,b+3) = sqrt( a+2*a+2+b+3*b+3 ) = sqrt( a+2a+2+b+3b+3 ) = sqrt( 3a+4b+5 ) 2 2 replyShare Please log in or register to add a comment.
Best answer 18 18 votes #define hypotenuse (a, b) sqrt (a*a+b*b); hypotenuse(a+2,b+3) after macro expansion it will become sqrt(a+2*a+2+b+3*b+3) Now after evaluating you will get D. Sumit1311 answered Feb 3, 2016 • selected Feb 3, 2016 by Purple Sumit1311 comment Share Follow See all 6 Comments 6 6 Comments reply Show 3 previous comments SPluto commented Feb 27, 2019 reply Follow flag @dattasai and @Taiyaba Khatoon 'Macro expansion' means replacing a macro call in a program, by the definition of that macro. Here, the macro call hypotenuse(a+2,b+3), wherever it appears in the program, is replaced by sqrt(a+2*a+2+b+3*b+3) * has higher precedence than +, so the expression evaluates to $a + 2a + 2 + b + 3b + 3 = 3a + 4b +5$, instead of $\left ( a+2 \right )^{2} + \left ( b+3 \right )^{2}$ 4 4 replyShare JashanArora commented Dec 7, 2019 reply Follow flag Would ((a+2),(b+3)) have worked fine? 0 0 replyShare Aman7982 commented Apr 21 reply Follow flag yes for sure 0 0 replyShare Please log in or register to add a comment.
2 2 votes answer D Source - http://www.cprogramming.com/tutorial/cpreprocessor.html Regina Phalange answered Apr 1, 2017 Regina Phalange comment Share Follow 0 reply Please log in or register to add a comment.