In this lab you will practice using variables and constants of type int and double, using integral and floating point expressions, and outputting variables to the display. Be sure to read this lab thoroughly, especially the Hand-in Procedure.
Write a complete program that:
FORMULA | DATA TYPES |
---|---|
5 + 2 | int |
5 - 2 | int |
5 * 2 | int |
5 / 2 | int |
5 % 2 | int |
5.0 / 2.0 | double |
Use the data type specified with the values 5, 2, 5.0, 2.0 as defined constants. The result of the expression should be saved in an appropriate variable which is then output to the terminal along with the informative message.
See the example output for examples and formatting.
An example of an interaction with your program is shown below, your output should match these examples exactly.
Alexs-iMac:lab1a alex$ g++ -Wall -pedantic -Werror main.cpp Alexs-iMac:lab1a alex$ ./a.out 5 + 2 = 7 5 - 2 = 3 5 * 2 = 10 5 / 2 = 2 5 % 2 = 1 5.0 / 2.0 = 2.5
main.cpp
. Do not ignore this step or save your file(s) with different names..cpp
file prior to the deadline to receive full credit. Any submissions after the deadline will be subject to the class’ late policy.