my counter isnt work right anyone know why???? thanks.
Code:
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<fstream>
using namespace std;
const int ARRAY_LENGTH = 8;
int readData(int range[8]);
void printResults(int range[8]);
int main()
{
//Declaration Section
int range8[ARRAY_LENGTH];
int thearray8[ARRAY_LENGTH];
readData(range8);
printResults(thearray8);
system("PAUSE");
return 0;
}//end of main
int readData(int range[8])
{
int grade;
int grades[17] = {35, 23, 23, 64, 75, 35, 23, 23, 64, 75, 35, 23, 23, 64, 75, 35, 23};
ifstream infile;
infile.open("C:/Documents and Settings/SmOkEbLaCk/Desktop/projects/proj8.txt");
infile>>grade;
while (infile)
{
if ((grade>=0) && (grade<=24))
range[1]++;
else if ((grade>=25) && (grade<=49))
range[2]++;
else if ((grade>=50) && (grade<=74))
range[3]++;
else if ((grade>=75) && (grade<=99))
range[4]++;
else if ((grade>=100) && (grade<=124))
range[5]++;
else if ((grade>=125) && (grade<=149))
range[6]++;
else if ((grade>=150) && (grade<=174))
range[7]++;
else
range[8]++;
infile>>grade;
}
infile.close();
return range[8];
}//end of function reading data
void printResults(int range[8])
{
cout<<" RANGE: NUMBER OF STUDENTS:"<<endl;
cout<<" 0 - 24 "<<range[1]<<endl;
cout<<" 25 - 49 "<<range[2]<<endl;
cout<<" 50 - 74 "<<range[3]<<endl;
cout<<" 75 - 99 "<<range[4]<<endl;
cout<<" 100 - 124 "<<range[5]<<endl;
cout<<" 125 - 149 "<<range[6]<<endl;
cout<<" 150 - 174 "<<range[7]<<endl;
cout<<" 175 - 200 "<<range[8]<<endl<<endl;
}//end of function printing results