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 56 57 58 59 60 61 62 63 64 65 66 67
|
#include <iostream>
using namespace std;
int minimum(int, int);
void minmax(int &, int &, int, int);
int main()
{
int num1, num2;
int min, max;
cout << "please provide two numbers" << endl;
cin >> num1 >> num2;
//call mininum function
min = minimum(num1, num2);
cout << "the minimum is " << min << endl;
//call minmax function
minmax(min, max, num1, num2);
cout << "The minimum is " << min << endl;
cout << "The maximum is " << max << endl;
return 0;
}
/*******************************************
Function: minimum
Input: two numbers, num1 and num2 (integers)
Output: The minimum of the two numbers (min)
********************************************/
int minimum(int num1, int num2)
{
if (num1 > num2)
{
return num2;
}
else
{
return num1;
}
}
/********************************************************
Function: minmax()
Input: min (int &)
max (int &)
num1 (int)
num2 (int)
Output: no formal return but a modifcation of min and max
*******************************************************/
void minmax(int &min, int &max, int num1, int num2)
{
if (num1>num2)
{
max = num1;
min = num2;
}
else
{
max = num2;
min = num1;
}
}
|