Program-Defined Value Returning Function - 3 Test Scores Averaged

This may seem redundant, as I know I have seen at least one thread on this exact topic, but it seemed to vary from what I had, and I couldn't quite get the answer I was looking for from there. So here goes, and as always, any and all help is greatly appreciated. The program is supposed to average 3 test scores and return the result. The scores are per input given by the user. I feel like I am very close, but I am not sure what exactly is going wrong. I am just learning about value returning functions, so this is a bit of a roadblock until I can get this. The code itself does not show any syntax errors, which makes it all the more difficult, but the output console says "fatal error LNK1120: 2 unresolved externals". I hope I'm as close as I think, but time will tell I suppose. And thanks again for any help. I do truly appreciate the time.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
  

#include <iostream>
#include <iomanip>
using namespace std;

//function prototypes
double getScore();
double testAverage(int tally);

int main ()
{
	//initialize variables

double score1 = 0.0;
double score2 = 0.0;
double score3 = 0.0;
double testScore = 0.0;
double result = 0.0;

//get scores

score1 = getScore();
score2 = getScore();
score3 = getScore();

//add scores
testScore = score1 + score2 + score3;

//get result of averaging test scores
result = testAverage(testScore);

//display result
cout << "Average of test scores is " << result << "." << endl;

system ("pause");
return 0;
} //end of main function

//***function definitions***

double getScore()
{
	double sum = 0;
	cout << "Input Score: ";
	cin >> sum;
	return sum;
}

double getAverage(int tally)
{
	double average = 0.0;
	average = (double) tally / 3;
	return average;
}

Last edited on
The function definition uses the name getAverage, but the function prototype and call in main use the name testAverage - you may have changed the name and just didn't update it in one place?
Last edited on
Well, as I figured, it was something really simple. And I appreciate you letting me know that wildblue. Sometimes a second pair of eyes helps. I found that in addition, I saved the file incorrectly somehow. I made the change you suggested, resaved the file in the correct format, and voila, its good to go. Thanks again. I, like many others, would be lost in the dark without the incredible help on this site from people like yourself.
Topic archived. No new replies allowed.