Programming in C - Constants, Variables and Data Types

15. Consider the following statement
#define hypotenuse (a, b) sqrt (a*a + b*b);
The macro-call hypotenuse (a + 2, b + 3);

  • Option : D
  • Explanation :
    A macro is defined with, hypotenuse (a, b) sqrt (a*a+b*b);
    call hypotenuse(a+2,b+3);
    hypotenuse = sqrt (a+2*a+2 + b+3*b+3)
    = sqrt (a + 2a + 2 + b + 3b + 3)
    = sqrt (3a + 4b + 5)
Cancel reply
Cancel reply