So I pulled this from the C++ tutorial here and played around with it to make it into a program that averages ten grades. How ever when I input all negative grades it gives a negative average. How would I and where would I input an if statement(not sure if this is what I would use) that would say basically if the average is less than zero than display ---%.
Thanks for your help I'm pretty new at all of this.
Code:
int main()
{
int grade[10];
int i,sum=0, avg=0;
int max=0,min=100;
for(i=0;i<10;i++)
{
cout << "Grade " << i+1 << ": ";
cin >> grade[i];
}
for(i=0;i<10;i++)
{
sum=sum+grade[i];
if(grade[i]>max)
{
max=grade[i];
}
if(grade[i]<min)
{
min=grade[i];
}
}
avg=sum/10;
cout << "Average Grade: " << avg << "%" << endl;
return 0;
}