This code will not assign any values to min and max. It just returns zero for their values. I need to find the largest and smallest number in the array. Any suggestions?
#include <iostream>
#include <cmath>
void foo(int baz[], int i, int min, int max);
usingnamespace std;
int main()
{
int max, min, baz[5], i;
for (i = 0; i < 5; i++)
{
cin >> baz[i];
}
cout << baz[0] << baz[1] << baz [2];
foo(baz, i, min, max);
cout << "The maximun is " << max << "." << endl;
cout << "The minnimum is " << min << "." << endl;
return 0;
}
void foo(int baz[], int i, int min, int max)
{
for (i = 0; i < 5; i++)
{
if (baz[i] > max)
max = baz[i];
if (baz[i] < min)
min = baz[i];
}
}