Using the vi editor, write a C program on the Sun cluster that allows the user to choose from a menu of mathematical functions. Some of these functions will be standard C functions (see appendix B of the text), and some you will need to write yourself. After making a selection, the user should be prompted for whatever input is appropriate. Your program should then compute and display the appropriate result. This result should also be returned and stored in a variable, as one of the menu options should be to redisplay the result of the previous computation.
These options should be displayed as a numbered list, and the user should choose their selection by number.
dval
is:
scanf("%lf", &dval);The
l
is required, as "%f"
will not work correctly.
This statement will correctly read integer values into the double variable
(i.e. the user does not have to enter 3.0
, just 3
).
More detailed specifications for each function are:
base
and exp
, then the value
of base
(i.e. base
to the exp
power) should be calculated, printed, and returned by the function.low
and high
. The value of:
low + (low + 1) + (low + 2) + ... + (high - 1) + highshould be computed, printed, and returned by the function. If
low
high
, the value computed should be low
.
In all cases, you can assume that the user will not enter anything except an integer or a double, as appropriate.