Hi i am a beginner in c++ and just start learning array, i am not able to output the average any idea why ???
#include<iostream>
using namespace std;
int main ()
{
const int MAX=200;
int age[MAX],i=0,size,sum,avg,highest=0,lowest=9999;
cout<<"Please enter ages:< type 0 to endl!> \n";
cin>>age[i];
while (age[i] != 0 )
{
i++;
cin>>age[i];
sum= sum +age[i];
avg=1.0*sum/avg;
}
size=i;
cout<<size<<" ages entered: ";
for (int i=0;i<size;i++)
cout<<"The average of all students is "<< avg;
cout<<endl;
Sort out your display loop. Once you can loop through you result you'll be able to do other things to, like counting the number of entries which are older than 20.