Topical Information

This lab will help familiarize you with the modulo operator (%) (as well as main program structure, data types, input, output, etc.).

Program Information

Write a program that reads in two whole numbered values from the user. After you've retrieved the two values, perform modulo (remainder) operations on them -- in all 4 possible combinations -- storing the results. Finally report the answers in a nice readable fashion.


As an example, you might have the program interaction look something like (the parts in red are typed by the user):

$ mod.out

                 Welcome to the Modulo Calculation Program!!!

Please enter your two numbers:  12 40

Thank you!!  You've entered 12 and 40!  Calculating...

Done.

12 mod 12 = 0
12 mod 40 = 12
40 mod 12 = 4
40 mod 40 = 0

Thank you for using the MCP!!

Endeavor to have a entertaining day!

$

Thought Provoking Questions

  1. Can your variables be floating point?

  2. How many variables do you need for this program? (Give upper and lower bounds.)

  3. What happens when the first value is larger than the second?

  4. What if the second is the larger?

  5. What if both values are the same?

  6. What if the signs of the values differ? Both negative?

  7. What if one of the values is 0? Does it seem to matter which one it is? How might you decide?

This assignment would have been (Level 1).