My program is returning a value of the score array instead of the average. I am guessing the problem has to do with the type conversions.
#include <iostream>
using namespace std;
float average(int length, int array[]);
int main(){
int N;
cout << "Enter length: ";
cin >> N;
cout << endl;
int scores[N];
for(int i = 0; i < N; i++){
cout << "Enter score: ";
cin >> scores[i];
}
cout << average(N, scores);
return 0;
}
float average(int length, int array[]){
int sum = 0;
for(int i = 0; i < length; i++){
sum += array[i];
}
return (sum / length);
}