This is my first post and I am just starting with arrays, but I am still stuck on how this function is suppose to work. I had to make two void functions and two-value returning functions. Main should call the getTestScores and get three test scores, then it should call calcAverage value returning function which calculates and returns the average then main should call displayAverage void function. This code does compile, but I am pretty sure that it is only because I tried to fix the mistakes rather than fix the code. I honestly do not know though how to formulate how I want to say it all within my code.
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
//Program functions
void getTestScores(int &num1,int &num2,int &num3);
double calcAverage(double calculation);
void displayAverage(double display);
int main ()
//declared variables of main
{
int score1 = 0;
int score2 = 0;
int score3 = 0;
double display = 0.0;
double calculation = 0.0;
//starts program
getTestScores(score1, score2, score3);
calcAverage(calculation);
displayAverage(display);
system("pause");
return 0;
}
//****Function Prototypes****
//gets the 3 test scores
void getTestScores(int &num1, int &num2, int &num3)
{
cout << "Enter first test score" << endl;
cin >> num1;
cout << "Enter second test score" << endl;
cin >> num2;
cout << "Enter third test score" << endl;
cin >> num3;
}
//calculates average
double calcAverage(double calculation)
{
double average = 0.0;
int num1 = 0;
int num2 = 0;
int num3 = 0;
average = (num1 + num2 + num3) / 3;
calculation == average;
return calculation;
}
//displays the average
void displayAverage(double display)
{
cout << "The average of the three numbers is: " << display << endl;
}