Help with array functions
Here is my program:
#include<iostream>
#include<fstream>
using namespace std;
ifstream inFile;
void getData(ifstream& inputFile, string s[], int sList[], int& size, int maxSize);
void printResult(string s[], int size, double avg);
int sumScores(int list[], int size);
int maxIndex(int list[], int size);
const int NO_OF_STUDENTS = 50;
int main()
{
string s[NO_OF_STUDENTS];
int sList[NO_OF_STUDENTS];
int size = 0;
int total = 0;
int max;
inFile.open("studentdata.txt");
getData(inFile, s, sList, size, NO_OF_STUDENTS);
total = sumScores(sList, size);
cout<<"Average is: "<<total/size<<endl;
system("PAUSE");
return 0;
}
void getData(ifstream& inputFile, string s[], int sList[], int& size, int maxSize)
{
int i = 0;
while(inFile&&i<NO_OF_STUDENTS)
{
inFile>>s[i];
inFile>>sList[i];
i++;
size++;
}
size-=1;
cout<<size<<endl;
}
void printResult(string s[], int size, double avg)
{
}
int sumScores(int list[], int size)
{
int total = 0;
for(int i = 0; i<=size; i++)
{
total = total + list[i];
}
return total;
}
int maxIndex(int list[], int size)
{
int index;
int maxIndex = 0;
for(index = 1; index < size; index++)
{
if(list[maxIndex] < list[index])
maxIndex = index;
cout<<maxIndex<<" "<<index<<endl;
}
return maxIndex;
}

