LAB EXERCISE
MATH
Background:
1. The largest and smallest integers and float values are defined in two separate header files:
limits.h
float.h
2. For example, the largest 2-byte integer is 32767.
3. Here are the names of the constants:
limits.h
INT_MAX largest 2-byte integer
INT_MIN smallest 2-byte integer
UINT_MAX largest unsigned (positives only) 2-byte integer
LONG_MAX largest 4-byte integer
LONG_MIN smallest 4-byte integer
ULONG_MAX largest unsigned (positives only) 4-byte integer
float.h
FLT_MAX largest 4-byte float
FLT_MIN smallest 4-byte float
DBL_MAX largest 8-byte float
DBL_MIN smallest 8-byte float
Assignment:
1. Write a program to solve the math expressions shown below.
2. The program must store each calculated result in an appropriate variable.
3. The program must print out the math expression and result as follows:
2 + 3 = 5
17 % 4 = 1
4. You are to solve the following problems:
4 + 9 46 / 7 46 % 7 2 * 3.0
|
float (25) / 4 int (7.75) + 2 int ('P') char (105)
|
5. The work will look something like this:
answer = 4 + 9;
cout << "4 + 9 = " << answer << endl;
6. Include the header files limits.h and float.h in your program.
#include <limits.h>
#include <float.h>
Print out all the constants listed in Background: section 3. For example:
cout << "The largest 2-byte integer = " << INT_MAX << endl;
Instructions:
1. After completing the program, print your source code and a run output to the printer.
2. Make sure your name is documented near the top of your source code.