First, I need to rewrite the program to incorporate functions. And there should be a value returning function that returns an int that the user entered. It will be called 5 times, once for each integer input.
After I compile the program, I need to modify the program again and replace the output statements with a call to a non-value returning function PrintAvg( ) that takes one parameter which is the calculated average. The function should print the avg to the screen just as the main( ) did originally.
I'm lost on how to complete these steps, I need some help on where to start, and some kind of an example to get me going. Thanks!
Here is the program below that I have originally made (and needs to be modified):
#include <iostream>
using namespace std;
int main(void)
{
int num1;
int num2;
int num3;
int num4;
int num5;
float avg;
cout << "Please enter a number: ";
cin >> num1;
cout << "Please enter a number: ";
cin >> num2;
cout << "Please enter a number: ";
cin >> num3;
cout << "Please enter a number: ";
cin >> num4;
cout << "Please enter a number: ";
cin >> num5;
avg = (num1 + num2 + num3 + num4 + num5)/5.0;
cout << "The average is " << avg << endl << endl; return 0;
}