Okay what can I do to return these arrays properly, at the moment it is taking the lowest of the first row and it wont change for any other.
And the average is doing the same.
Code:
//Low Score
#include<iostream>
#include<iomanip>
using namespace std;
void getData(int score[][4], int rows)
{
for(int R=0; R < rows; R++)
{
for(int C=0; C < 4; C++)
{
do
{
cout << "Enter test score " << (C+1) << " for student " << (R+1) << ": ";
cin >> score[R][C];
}while(score[R][C] < 0 || score[R][C] > 100);
}
cout << endl;
}
}
int findLowest(int score[][4], int rows)
{
const int LOWS = 3;
int arr[LOWS];
for(int R=0; R < rows; R++)
{
int low = 100;
for(int C=0; C < 4; C++)
{
if (score[R][C] < low)
low = score[R][C];
}
arr[R] = low;
return *arr;
}
}
double calcAvg(int score[][4], int rows, int low)
{
const int AVGS = 3;
double arr[AVGS];
double avg;
for(int R=0; R < rows; R++)
{
int TOT=0;
for(int C=0; C < 4; C++)
{
TOT += score[R][C];
}
avg = (TOT - low) / 3.0;
arr[R] = avg;
return *arr;
}
}
void display(int score[][4], int rows, int low, double avg)
{
for(int R=0; R < rows; R++)
{
for(int C=0; C < 4; C++)
{
cout << "Score " << (C+1) << " for student " << (R+1) << ": " << score[R][C] << endl;
}
cout << "Dropped Grade: " << low << endl;
cout << "Average: " << avg << endl;
cout << endl;
}
}
int main()
{
int sc[3][4], low;
double avg;
getData(sc, 3);
low = findLowest(sc, 3);
avg = calcAvg(sc, 3, low);
display(sc, 3, low, avg);
return 0;
}