creating a program that calculates the average of the three test scores. The program should contain two value-returning functions(main and calcave)and two void function(getScore and displayAve).The main function should call the void getScore function to get the three test score . The test score may contain a decimal place. The main function then should call the value-returning calcave funtion to calculate and return the average of the three test scores. When the calcave function has completed its task, the main function should call the void displayAve funtion to display the average of the three test scores on the screen. Dislay the average with one decimal place. Use a sentinelvalue to end the program.
My problem is how do i loop it here is my code
Well, I believe the problem here is that you're not using calcave as you should- that is what your main should call first, and that is what should calculate the average, not the disave proc. The main function would call the calcave proc, passing to it ts1, ts2, and ts3. It would then calculate the average, and return that new value which you would store in a variable. You would then call the disave proc, passing to it the average that you just stored to a variable. That wold then simply display the average. As for your main, you shouldn't be asking for scores in it. It should simply say something along the lines "Please input scores" and then call the proc getscores() to set ts1, ts2, and ts3 to their respective values (there's more to it than simply using cin, but it's not too advanced, so it shouldn't be too hard to figure out). So all the main would do in the end is call getscores, call calcave while passing ts1, ts2, and ts3, and then call disave while passing the resultant value from calcave.
Yes. That looks much better. However, when you used the calcaverage function, you didn't pass to it the current value of totalscore. Since totalscore isn't a global variable, it won't work when you try it. Also, your calcaverage function returns totalscore instead of average. Your getscore function should actually be using score <=0 and score >= 100, since it should include 0.1 and 100. Also, for this assignment, are you allowed to use pointers? If not, you will need a different method than what you did with getscore.