Exercise: Create Safe Macros
Write code to solve the problem.
Question
Macros can simplify repeated computations, but they must be written carefully to avoid unexpected behavior.
Your task is to define two macros:
SQUARE(x): Returns the square of a number.MAX(a, b): Returns the larger of two values.
These macros must work correctly even when expressions are passed as arguments.
Expected output:
Square of 3 is 9Max of 3 and 5 is 5Square of (a + 1) is 16Max of (a + 2) and (b - 1) is 5
Exercise: Create Safe Macros
Write code to solve the problem.
Question
Macros can simplify repeated computations, but they must be written carefully to avoid unexpected behavior.
Your task is to define two macros:
SQUARE(x): Returns the square of a number.MAX(a, b): Returns the larger of two values.
These macros must work correctly even when expressions are passed as arguments.
Expected output:
Square of 3 is 9Max of 3 and 5 is 5Square of (a + 1) is 16Max of (a + 2) and (b - 1) is 5