in c Write a modular program that accepts up to 20 integer t

in c++ Write a modular program that accepts up to 20 integer test score in the range of 0 to 100 from the user and stores them in an aray. Then main should report how many perfect scores were entered (i.e., scores of 100), using a value-returning countPerfect function to help it.

Solution

Count.cpp

#include <iostream>

using namespace std;
int countPerfect (int a[], int size);
int main()
{
int scores[20];
cout<<\"Enter 20 test scores in the range of 0 to 100: \";
for(int i=0; i<20; i++){
cin >> scores[i];
}
int count = countPerfect(scores,20);
cout<<\"Number of erfect scores were entered: \"<<count<<endl;

return 0;
}

int countPerfect (int a[], int size){
int count = 0;
for(int i=0; i<size; i++){
if(a[i] == 100){
count++;
}
}
return count;
}

Output:

sh-4.3$ g++ -std=c++11 -o main *.cpp                                                                                                                                                                                        

sh-4.3$ main                                                                                                                                                                                                                

Enter 20 test scores in the range of 0 to 100: 20 30 40 50 60 70 80 90 100 10 20 30 100 100 45 56 67 100 99 87                                                                                                              

Number of erfect scores were entered: 4

in c++ Write a modular program that accepts up to 20 integer test score in the range of 0 to 100 from the user and stores them in an aray. Then main should repo

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site