lesson 10 bigsmall c
[[lesson_10_bigsmall_c]] last edit on Aug 18, 2005 6:09 AM by rescued_by_c

[user02@FC4 Lesson10]$ cat -n bigsmall.c
   1  #include <stdio.h>
   2
   3  void show_big_and_little(int a, int b, int c)
   4  {
   5     int small = a;
   6     int big = a;

   7
   8     if (b > big)
   9        big = b;
  10     if (b < small)
  11        small = b;
  12     if (c > big)
  13        big = c;
  14     if (c < small)
  15        small = c;
  16
  17     printf("The biggest value is %d\n", big);
  18     printf("The smallest value is %d\n", small);
  19  }
  20
  21  int main(void)
  22  {
  23     show_big_and_little(1, 2, 3);
  24     show_big_and_little(500, 0, -500);
  25     show_big_and_little(1001, 1001, 1001);
  26
  27     return 0;
  28  }
[user02@FC4 Lesson10]$ gcc -o bigsmall bigsmall.c
[user02@FC4 Lesson10]$ ./bigsmall
The biggest value is 3
The smallest value is 1
The biggest value is 500
The smallest value is -500
The biggest value is 1001
The smallest value is 1001
[user02@FC4 Lesson10]$