Write a function that will read a collection of examination scores ranging in value from 1 to 100. Your subprogram should count and print the number of scores in the outstanding category ( 90 – 100), the number of scores in the satisfactory category ( 60-89), and the number of scores in the unsatisfactory category ( 1-59). The test data for the subprogram is :
63 75 72
72 78 67
80 63 75
90 89 43
59 99 82
12 100
#include <iostream>
using namespace std;
void catagorize(int score[17])
{
int j=0; //counters for 3
arrays for 3 categories
int k=0;
int l=0;
int count1,count2,count3;
int
outstanding[17],satisfactory[17],unsatisfactory[17]; //three arrays
for 3 categories
count1=count2=count3=0;
for(int i=0;i<17;i++)
{
if(score[i] >=90 &&
score[i] <=100)
{
outstanding[j] = score[i];
j++;
count1++;
//increment count1
}
else if(score[i] >=60 &&
score[i] <=89)
{
count2++;
//increment count2 for satisfactory category
satisfactory[k] = score[i];
k++;
}
else if(score[i] >=1 &&
score[i] <=59)
{
count3++; //increment count for unsatisfactory
category
unsatisfactory[l]= score[i];
l++;
}
}
//display different caregories of
score with counts
cout<<"\nScores in
outstanding category : "<<count1<<endl;
for(j=0;j<count1;j++)
cout<<outstanding[j]<<"\t";
cout<<"\nScores in
satisfactory category : "<<count2<<endl;
for(j=0;j<count2;j++)
cout<<satisfactory[j]<<"\t";
cout<<"\nScores in
unsatisfactor category : "<<count3<<endl;
for(j=0;j<count3;j++)
cout<<unsatisfactory[j]<<"\t";
}
int main() {
int score[17];
cout<<"Enter scores \n";
for(int i=0;i<17;i++)
{
cin>>score[i];
}
catagorize(score);
return 0;
}
output:
Enter scores 63 75 72 72 78 67 80 63 75 90 89 43 59 99 82 12 100 Scores in outstanding category : 3 90 99 100 Scores in satisfactory category : 11 63 75 72 72 78 67 80 63 75 89 82 Scores in unsatisfactor category : 3 43 55 12
Get Answers For Free
Most questions answered within 1 hours.