I will be working on a program this evening to calculate the average of test scores while dropping the lowest test score.
I'll have a few questions, starting with this one. If you are willing to help, I'd greatly appreciate it. I have no tutors at my college that can assist me, so I have to rely on people helping me through here. Thanks ahead of time!
The first would be,
If I want to create a function to ask for the score to be inputed. They will enter 5 scores. How can I make it so when they enter it my cin>> will change for each score? So I can enter many test scores within that function, without creating separate cin>>'s. Any suggestions?
Try an array and a loop. Do you know how they work? You can find it in the documentation on this website. Arrays and loops (as well as any container with a subscript) play very nicely together.
But I see what you mean.
Is there anyway of me using this code that works and placing it in functions to fulfill my assignment. I understand this code, but I don't see how I can include functions.
#include <iostream>
using namespace std;
int main()
{
int scores[5], temp;
do {
cout << "Please enter a score: ";
cin >> scores[0];
} while(scores[0] < 0 || scores[0] > 100);
for(int i = 1; i < 5; i++){
do {
cout << "\n\nPlease enter a score: ";
cin >> scores[i];
} while(scores[i] < 0 || scores[i] > 100);
Undeniably, vectors will streamline the performance of the program. I don't deny that much. But although I'd gladly use vectors for pretty much any personal application, the OP is doing this for a course and (evidently) has not covered vectors in class yet. I've found that my teachers *really* don't like it when I take advantage of prior experience to do something not yet covered.
@OP: Here's how you use vectors. The entire interface can be examined here: http://www.cplusplus.com/reference/stl/vector/
If you aren't experienced with STL or the class system, I'd honestly suggest you stick to arrays for the simplicity, even though vectors totally kick ass... I wonder if anybody's written an article on this website for basics of STL. I'm certainly not qualified enough to do it.
You still don't have code tags or indentation. With that amount of code, I'm not inclined to read anything without code tags.
And read over your error, then compare it to the code or section it's referring to. Do you see what the problem is? Errors are strikingly intuitive.