i stuck on b n c
A list of positive numbers is read into an array from the keyboard. The list finishes when a
number 0 is typed from the keyboard.
a. Find the average of the numbers entered
b. Print out all those below the average
c. Print out all those above the average
#include <iostream>
using namespace std;
int main()
{
int above=0,below=1,number,sum=0;
int count=0;
float average;
while(1)
{
cout<<"Enter 0 if you finished: "; cin>>number;
if(number==0)
break;
else if(number<0)
{ cout<<"\7";
cout<<"\nEnter a positive number.\n";continue;}
below=(number<below)?number:below;
sum+=number;
count++;
}
average=float(sum)/float(count);
for(count = 0;count <=average;count++);
{
if(numbers[count]>=average)
{above++;}
else
{below++;}
}
cout<<"\nYou entered " << count << " numbers."<<endl;
cout<<"Their average is : "<<average<<endl;
cout<<"Numbers above average : "<<above<<endl;
cout<<"Numbers below average : "<<below<<endl;
return 0;
}