I have to write a modular program that accepts at least 10 integer test scores from the user and stores them in an array. Then main should display how many perfect scores were entered (i.e., scores of 100), using a value-returning countPerfect function to help it. I also have to validate the input to not accept scores less than 0 or gerater than 100. I have the basics done, but i'm having trouble figuring the rest out. I am new to using arrays.
#include <iostream>
usingnamespace std;
void countPerfect(int intArray[], int perfect); //Function prototype
int main()
{
int score;
constint TEST_SCORES = 10;
int testScores[TEST_SCORES]; // holds test scores for 10 tests
cout << "Enter ten " << TEST_SCORES
<< "test scores. " ;
for (score = 0; score < TEST_SCORES; score++)
cin >> testScores[score]; // I've figured this out
cout << "The number of perfect scores was";
countPerfect(testScores, TEST_SCORES); //need to print actual data, not just spit out whole array
system("pause");
return 0;
}
void countPerfect(int nums[], int perfect) //this needs to turn into a function that calculates the number of perfect scores entered
{
for (int index = 0; index < perfect; index++)
cout << nums[index]<< " ";
cout << endl;
}
I'm a little unsure of whether you need reference arguments or not during a function call, but they are definitely needed for returning more than one value from a function call.