Hello so I'm having an issue with this program I set the user to input up to 20 grades once the user has inputted let's say 8 grades they can exit if the like or continue imputing grades. After the user has done all that the program is suppose to calculate the mean and median of the numbers they imputed. Now the problem is that I don't know how to calculate the mean I get the median perfectly but I'm having issues getting the mean.
#include<iostream>
#include<string>
usingnamespace std;
int main(void)
{
int x, i, sum, suml, counter, inner, outer, mean;
constint f=20, l=0;
int igrade[f];
x=0;
counter=0;
cout<<"Enter you first grade: ";
cin>>igrade[x];
while (x<20 && igrade[x]>0)
{counter++; x++;
cout<<"Enter your next grade or type (-esc) to get results: ";
cin>>igrade[x];
}
cin.ignore(1);
for(i=0;i<=x;i++)
{
suml= i / counter;// Here is were I try o calculate the mean but here is the reouble????
}
//Sort
for (outer = 0; outer < x+1; outer++)
for (inner = 0; inner < (x+1)-1; inner++ )
if (igrade[inner] > igrade[inner+1])
swap(igrade[inner], igrade[inner+1]);
sum=(x+1)/2;
cout<<"MEDIAN= "<<igrade[sum];
cout<<endl<<endl;
cout<<"\nMean value is "<<suml<<endl;
system("pause");
return 0;
}