So I can call the getscore funtion from the main funtion and validate the data, but my problem is getting the main function to call the calcaverage funtion to calculate the validated data. I've been toying around with it all day and the examples from my book have yet to get me anywhere. I would greatly appreciate any tips.
One problem is that each time you call getscore, score gets overwritten with the new value, so that by the time you get to calcaverage, score has the value of score5 instead of the total. You need to keep a running total of score in main.
after you call getscore each time, do something like
totalscore += score;
Or alternatively, you could add a totalscore parameter to getscore(), then you would only have to use the line once.
Another problem is that the calcaverage() function has no idea what score is. Since that variable is declared in main, it goes out of scope when you call getscore. You have to send the function that variable in an argument.
One more thing, you have calcaverage defined as a void function (meaning it doesn't return a value), and then you try to return average. If you want a good average, that variable should also be a double, not an int.
Try fixing some of these problems, then repost the code and we can take a new look at it.
calcaverage cannot take 0 arguments because the function has one parameter, totalscore.
You need to pass totalscore to the function, then it calculates and returns the average.
average=calcaverage(totalscore);
I don't see why you are passing it by reference, you aren't modifying the value inside of the function (although it doesn't really make much difference).
I'm not sure what you mean. My assignment called for me to inlcude some sort of reference variable in getscore(), so I looked at a group of examples to express what was asked. Firedraco, in what way would you have approached it?