Array Problem

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?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 #include <iostream>
#include <cmath>
void foo(int baz[], int i, int min, int max);
using namespace 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];
    }
}
Last edited on
Topic archived. No new replies allowed.