Look up the man page for the functions in the following table:
The Calculator program can only perform integer math. Extend Calculator to do double-precision floating-point computations. These double-precision values will use the double data type, rather than the int data type. For example, you need to change the calculate function to accept and return doubles instead of ints. Feel free to skip ahead to Chapter 6 if you want to learn more about these data types. But this is mostly an opportunity to practice using Xcode to build and run a program.
The "3 printf" and "3 scanf" man pages tell you how to read and write double-precision numbers to standard I/O. Make sure the decimal point is printed only when necessary:
Enter an expression: 1 + 2 1 + 2 = 3 Enter an expression: 1 + 2.1 1 + 2.1 = 3.1
Common mathematical functions and operators appear in the following table. Extend your Calculator changes in Exercise 2 to incorporate these new operators.
|Divide||"/"||/||x = y / z;|
|Integer Divide||"\"||/||x = (int)y / (int)z;|
|Modulo||"%"||%||x = (int)y % (int)z;|
|Power||"^"||pow()||x = pow(y, z);|
You need to add the following line of code near the top of Calculate.c, along with the other include statements: