0
Challenge num 12
(Test Score Calculation) Write a C++ program that reads an unspecified number of scores and determines how many scores are above or equal to the average and how many scores are below the average. Enter a negative number to signify the end of the input. Assume that the maximum number of scores is 100.
3 Réponses
0
Where's your attempt?
0
#include<iostream>
using namespace std;
int main()
{
int n,i;
int below=0,above=0;
float avg=0,p;
cout<<"enter size of array"<<" ";
cin>>n;
float a[n];
cout<<"enter scores ";
for(i=0;i<n;i++)
{
cin>>p;
if(p>0)
{
a[i]=p;
avg=avg+a[i];
continue;
}
else
break;
}
avg=avg/n;
for(i=0;i<n;i++)
{
if(a[i]<avg)
{
below=below+1;
}
if(a[i]>avg)
{
above=above+1;
}
}
cout<<endl;
cout<<"total no. of below avg. is "<<below;
cout<<endl;
cout<<"total no. of above avg. is "<<above;
return 0;
}
Here XD
0
I wanna figure out how many ways we can do it with