I am having some trouble getting my program to find the maximum and minimum values for a set of students GPA's. I can do this easily without using a function but when I include the function my program still runs fine but it does not calculate the maximum and minimum GPA's. I have debugged it as well and by the looks of things the program simply runs straight over it without looking at it. Your help would be greatly appreciated. This is what my code currently looks like:
#include <iostream>
using namespace std;
float array(int arr[], int size)
{
float max = 0;
float min = 4;
int i;
for (i = 0; i <= 2; i++)
{
if (arr[i] > max)
max = arr[i];
if (arr[i] < min)
min = arr[i];
}
cout << "Maximum GPA: " << max;
cout << "Minimum GPA: " << min;
}
int main(int argc, char** argv)
{
int ID[3];
float GPA[3];
int i;
for (i = 0; i <= 2; i++)
{
cout << "Please enter student ID and GPA: " << endl;
cin >> ID[i] >> GPA[i];
array[GPA, i];
}
for (i = 0; i <= 2; i++)
{
cout << endl << "Student ID: " << ID[i] << endl << "Student GPA: " << GPA[i] << endl;
}
return 0;
}