Need an opinion about the function of the following part

Can anyone help me about the function of the following part of a programm by givving me an example ?

if (x > y)
z = x;
if (x == y)
z = 0;
if (x < y)
z = y;
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
int foo(int x, int y) {
        int z;

        if (x > y) {
            z = x;
        }

        if ( x == y) {
            z = 0;
        }

        if ( x < y ) {
            z = y;
        }

        return z;
}
That code sets 'z' to the maximum value ( 'x' or 'y' ).
If 'x' and 'y' are the same, 'z' would be equal to zero.
Topic archived. No new replies allowed.