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:

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:

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