Exercises
-
E.4 Write a program that defines a macro with one argument to compute the volume of a sphere. The program should compute the volume for spheres of radii from 1 to 10 and print the results in tabular format. The formula for the volume of a sphere is
( 4.0 / 3 ) * π * r3
where π is
3.14159
. -
E.5 Write a program that produces the following output:
The sum of x and y is 13
The program should define macro
SUM
with two arguments,x
andy
, and useSUM
to produce the output. -
E.6 Write a program that uses macro
MINIMUM2
to determine the smaller of two numeric values. Input the values from the keyboard. -
E.7 Write a program that uses macro
MINIMUM3
to determine the smallest of three numeric values. MacroMINIMUM3
should use macro ...
Get C++ How to Program, 10/e 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.