[ create a new paste ] login | about

Link: http://codepad.org/luyIFIwo    [ raw code | output | fork ]

C, pasted on Nov 7:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <stdio.h>
int min3(int x, int y, int z) {
  if (x <= y && x <= z)
    return x;
  else if (y <= x && y <= z)
    return y;
  return z;
}

int main() {
  int x, y, z;
  x = 7; y = 5; z = 3; printf("min: %d\n", min3(x, y, z));
  x = 7; y = 2; z = 5; printf("min: %d\n", min3(x, y, z));
  x = 1; y = 7; z = 5; printf("min: %d\n", min3(x, y, z));
  return 0;
}
/* end */


Output:
1
2
3
min: 3
min: 2
min: 1


Create a new paste based on this one


Comments: