# Project #3

Math Calculator

40 points

You are to create a menu-driven program that will perform each of these operations:

1. Add two integers
2. Subtract two integer
3. Multiply two integers
4. Divide two integers
5. Calculate an integer raised to a positive integer power
6. Compute the GCD (Greatest Common Divisor) of two integers
7. Compute the factorial of an integer

q.    Quit

The following conditions must be met:

• It must have a menu that allows the user to choice which operation they want to perform.
• The user interface must be appropriate and informative, as always.
• The program should run until the user inputs a 'Q' or a 'q'.
• You must write and use functions (at least 7).
• You must handle any input domain error conditions, such as dividing by zero, and entering a negative power or factorial.  You do not have to worry about invalid integers being entered, such as characters entered instead of numbers, or entering a real number instead of an integer.
• Use looping implementations for computing power and factorial.  Use Euclid's looping algorithm to find GCD.

Euclid's Algorithm to find the Greatest Common Factor of two non-negative integers

if x < y, swap x and y     // x is the larger of the two integers
while y != 0
remainder = x mod y
x = y
y = remainder
return
x

You must name your project "project3.c".

C Language Hints

Note that while functions are required, no parameter passing is required.  The function should prompt for the inputs it needs and display its results.  You may want to write an additional function to display the menu.  The main() function is responsible for displaying the menu, or calling a function that does so, interpreting the choice, and calling the correct function for each menu section, excluding Q which exits the program.

Does it appear that the menu selections are all numeric?  While there are seven numeric menu selections, 'q' or 'Q'are not, so it is best to consider all menu inputs as character instead of numbers.  Working with a single digit number is as easy as working with an integer, just test for '1' instead of 1, '2' instead of 2, etc.

At the top of this program put the following comments:

• Your Name
• Project Number
• Date
Use Oncourse to submit electronic a copy of your Source File in its drop box by its due date.

### Grading scheme:

 Correct Result 20 points Readability (Code and Output) 20 points