Keeping track of numbers inside an array

okay well this program basically infiles grades and then find the highest, lowest and average. Then it's supposed to find how many grades are within the 50-59, 60-69, 70-79, 80-89, and 90-100 range. I am having trouble keeping track of how many numbers within the first array fall into those categories. This is the code I have so far:

//Christian Herrera
//Programming Fundamentals I
//05-10-13
//Final Exam

#include<iostream>
#include<iomanip>
#include<string>
#include<fstream>
using namespace std;

int highest(int[], int);
int lowest(int[], int size);
double average(int[],int);
void gradeDistribution(int[]&,int);

int main()
{
const int SIZE=20;
int grades[SIZE];

ifstream infile;
infile.open("values.txt");

for (int x=0; x<20; x++)
{
infile>>grades[x];
}
infile.close();

cout<<"The highest grade is: "<<highest(grades, SIZE)<<endl;
cout<<"The lowest grade is: "<<lowest(grades, SIZE)<<endl;
cout<<"The average grade is: "<<fixed<<showpoint<<setprecision(1)<<average(grades, SIZE)<<endl;
gradeDistribution(grades&, SIZE);



system("pause");
return 0;

}

int lowest(int grades[],int size)
{
int lowest=grades[0];
for(int count=1; count<size; count++)
{
if(grades[count]<lowest)
lowest=grades[count];
}
return lowest;
}

int highest(int grades[],int size)
{
int highest=grades[0];
for(int count=1; count<size; count++)
{
if(grades[count]>highest)
highest=grades[count];
}

return highest;
}

double average(int grades[],int size)
{
double average=0.0;
int total=0;
for(int count=0;count<size; count++)
{
total+=grades[count];
}
average=total/size;
return average;
}

void gradeDistribution(int grades[]&,int size)
{
int distribution[5]={0,0,0,0,0};
int total=0;
for(int x=0; x<20; x++)
{
if(grades[x]>=50&&grades[x]<=59)
{
total+=total;
total++;
distribution[0]=total;
}
else if(grades[x]>=60&&grades[x]<=69)
{
total+=total;
total++;
distribution[1]=total;
}
else if(grades[x]>=70&&grades[x]<=79)
{
total+=total;
total++;
distribution[2]=total;
}
else if(grades[x]>=80&&grades[x]<=89)
{
total+=total;
total++;
distribution[3]=total;
}
else
{
total+=total;
total++;
distribution[4]=total;
}

}
cout<<distribution[0]<<endl;
cout<<distribution[1]<<endl;
cout<<distribution[2]<<endl;
cout<<distribution[3]<<endl;
cout<<distribution[4]<<endl;
}
Elaborate your question, where are you having problem?
The problem is that when I cout the array in the gradeDistribution function, the numbers I'm supposed to get don't come up. Something is probably wrong with my counters. For every grade that is between 50-59 it needs to count them and put the final "total" in the first location of the array. In this case distribution[0]. In this function it has to read all the numbers from my grades[] array and count which ones fall into what category then place the amounts in the distribution[] array
1
2
3
total+=total;
total++;
distribution[4]=total;

This adds the previous total to the new one then adds 1.
Also all the distributions are using the same value for total.
It would be easier to just use
 
distribution[4]++;
Thank you so much! This definitely helped and I finally got it to work. Can't thank you enough!
Topic archived. No new replies allowed.