function problem

Hi guys, I'm really new to this. The problem is that I have to write a int function to get the lowest number out of 5 numbers, and the another float function to call the above function and only get the average of the highest 4 numbers in the function.
Something like this?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
int min5(int a, int b, int c, int d, int e)
{
    min(a, min(b, min(c, min(d, e))));
}

int ave5(int a, int b, int c, int d, int e)
{
    int minimum = min5(a,b,c,d,e);
    float average = 0;
    if (a != minimum) average += a;
    if (b != minimum) average += b;
    if (c != minimum) average += c;
    if (d != minimum) average += d;
    if (e != minimum) average += e;
    return average/4.f;
}
Thanks, this really helped alot.
Enjoy!
Topic archived. No new replies allowed.