I cant get the output to display the average, high, and low. Any hints?

/*	Write a program that prompts the user for test
	scores (doubles). The user enters -1 to stop the
	entry. After all of the test scores have been
	entered, calculate the average, the highest and 
	the lowest test score. Use the code below as a 
	template. Make sure you respond appropriately 
	when no test scores are entered. Use the 
	following screen shots as a guide.
*/

#include <iostream>
using namespace std;
int main()
{
double scores[75];
int counter = -1;
do
{
counter++;
cout << "Please enter a score (enter -1 to stop): ";
cin >> scores[counter];
} while (scores[counter] >= 0);

}

I am very new at C++, I dont know where or how to add the High, Low, and Average in?

Any help would be greatly appreciated.

Thanks,
Mac

Recommended Answers

All 3 Replies

You need to increment counter in while loop.

After the do-while loop is done you can calculate everything. You have the size of the set of scores, counter , so all you need to do is declare an integer as an index to use in a for loop, as well as three double's for the high, low and average.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.