Review Questions
Here are groups of one or more macros followed by a source code line that uses them. What code results in each case? Is it valid code?
#define FPM 5280 /* feet per mile */ dist = FPM * miles;
#define FEET 4 #define POD FEET + FEET plort = FEET * POD;
#define SIX = 6; nex = SIX;
#define NEW(X) X + 5 y = NEW(y); berg = NEW(berg) * lob; est = NEW(berg) / NEW(y); nilp = lob * NEW(-berg);
Fix the definition in 1.d. to make it more reliable.
Define a macro function that returns the minimum of two values.
Replace the even_gt() macro in Listing 16.4 with a macro of your own devising.
Define a macro function that prints the representations and the values of two integer expressions. For example, it might print
3+4 is 7 and 4*12 is 48 ...
Get C Primer Plus®, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.