lesson 10 bigsmall cpp
[[lesson_10_bigsmall_cpp]] last edit on Aug 18, 2005 6:04 AM by rescued_by_c

[user02@FC4 Lesson10]$ cat -n bigsmall.cpp
   1  #include <iostream>
   2  using namespace std;
   3
   4  void show_big_and_little(int a, int b, int c)
   5  {
   6     int small = a;
   7     int big = a;
   8
   9     if (b > big)
  10       big = b;
  11     if (b < small)
  12       small = b;
  13     if (c > big)
  14       big = c;
  15     if (c < small)
  16       small = c;
  17
  18     cout << "The biggest value is " << big << endl;
  19     cout << "The smallest value is " << small << endl;
  20  }
  21
  22  int main()
  23  {
  24     show_big_and_little(1, 2, 3);
  25     show_big_and_little(500, 0, -500);
  26     show_big_and_little(1001, 1001, 1001);
  27
  28     return 0;
  29  }
[user02@FC4 Lesson10]$ g++ -o bigsmall bigsmall.cpp
[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]$