Macros with Arguments
Completed
Define #define SQUARE(x) ((x) * (x)) and #define MAX(a, b) ((a) > (b) ? (a) : (b)). Read two numbers and print SQUARE(a + 1) and MAX(a, b).
Input
Two integers.
Output
Two lines.
Example
Input
3 8
Output
16 8
Editor
C
Hints
Wrap every macro argument in parentheses.
Solution explanation
Without the parentheses, SQUARE(a + 1) would expand to a + 1 * a + 1.
Show solution
#include <stdio.h>
#define SQUARE(x) ((x) * (x))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
int main() {
int a, b;
scanf("%d %d", &a, &b);
printf("%d\n%d\n", SQUARE(a + 1), MAX(a, b));
return 0;
}