Assignment I

Primary focus on chapter 6 Functions

For each problem:

Additional requirement:
In these problems, and all future problems, use functions.
Provide a function prototype for each function before the main function.
The function prototype should have descriptive names for the function and for each parameter.
Put very little code in the main function.
Each function should be preceded with a short comment giving:

Problem I1

In the main function, define four variables of type int, named: first, second, third, and total.
Write a function named getData that asks the user to input three integers and stores them in the variables first, second, and third which are in the main function.
Write a function named computeTotal that computes and returns the total of three integers.
Write a function named printAll that prints all the values in the format shown in the following sample:

1 + 2 + 3 = 6
  

Call the other three functions from the main function.

Test it once, with the values 4, 5, and 6.

Problem I2

In the main function, define five variables of type int, named: first, second, third, fourth, and total. Also in the main function, define three variables of type double named: decimalOne, decimalTwo and decimalTotal
Write one function named getData which asks the user for the data and puts it in first, second, third, fourth, decimalOne, and decimalTwo. (You may copy your getData from problem I1 and make additions to manage fourth, decimalOne, and decimalTwo.) Write a function named computeTotal which can take two, or three int arguments and returns an int. Write another function, also named computeTotal which takes four int arguments and returns an int. Write another function, also named computeTotal which takes two double arguments and returns a double. Write a function named printAll which takes three arguments of type int. Write a function named printAll which takes four arguments of type int. Write a function named printAll which takes five arguments of type int. Write a function named printAll which takes three arguments of type double.

In the main function, after calling the getData function make the following function calls:

Print the results int the formats shown in the following samples:

For integers:
1 + 2 + 3 = 6

For decimal numbers:
1.10 + 2.20 = 3.30
  

Test the program once with the values 4, 5, 6, 7, 8.1234, and 9.5678