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.

18th Dec 2020, 1:48 PM
Decoder 👩‍💻
3 Réponses
0
Where's your attempt?
18th Dec 2020, 1:50 PM
你知道規則,我也是
你知道規則,我也是 - avatar
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
18th Dec 2020, 1:55 PM
Decoder 👩‍💻
0
I wanna figure out how many ways we can do it with
18th Dec 2020, 1:56 PM
Decoder 👩‍💻