1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
#include <iostream>
using namespace std;
void smaller (int a, int b) // return the smaller of a and b (if they are equal then just return that value)
{
cout << "Between the numbers: " << a << " and " << b << endl;
if (a < b) // if a is less than b, then print a
{
cout << a << " is smaller." << endl;
}
else if (b < a) // if b is less than a, then print b
{
cout << b << " is smaller." << endl;
}
else //otherwise, if a is not smaller and b is not smaller, then print ...
{
cout << "The numbers have the same value." << endl;
}
cout << endl;
}
void bigger (int a, int b) // return the bigger of a and b (if they are equal then just return that value)
{
cout << "Between the numbers: " << a << " and " << b << endl;
if (a > b) // if a is greater than b, then print a
{
cout << a << " is bigger." << endl;
}
else if (b > a) // if b is greater than a, then print b
{
cout << b << " is bigger." << endl;
}
else // otherwise, if a is not bigger and b is not bigger, then print ...
{
cout << "The numbers have the same value." << endl;
}
cout << endl;
}
void smallest (int a, int b, int c) // return the smallest of a, b and c
{
smaller(a, b);
smaller(a, c);
}
int main ()
{
smaller (1, 8);
bigger (1, 8);
smallest (100, 232, 3423);
return 0;
}
|