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;
int myMaxFunc(int n1, int n2);
double myMaxFunc(double n1, double n2);
double myMaxFunc(double n1, int n2);
double myMaxFunc(int n1, double n2);
// PURPOSE OF THE PROGRAM
// takes 4 numbers and prints
// the largest number.
int main()
{
double maxDbl = myMaxFunc(1, 1.5);
//int maxInt = myMaxFunc(1, 1);
/*cout << "Enter the first number: ";
int num1;
cin >> num1;
cout << "Enter the second number: ";
int num2;
cin >> num2;
cout << "Enter the third number: ";
int num3;
cin >> num3;
cout << "Enter the last number: ";
int num4;
cin >> num4;
int maxNum = myMaxFunc(num1, num2);
maxNum = myMaxFunc(maxNum, num3);
maxNum = myMaxFunc(maxNum, num4);
cout << "The maximum number is " << maxNum << endl;
*/
system("PAUSE");
return 0;
}
double myMaxFunc(double n1, int n2)
{
return myMaxFunc(n1, (double)n2);
}
double myMaxFunc(int n1, double n2)
{
return myMaxFunc((double)n1, n2);
}
double myMaxFunc(double n1, double n2)
{
if (n1 > n2)
return n1;
else
return n2;
}
int myMaxFunc(int n1, int n2)
{
if (n1 > n2)
return n1;
else
return n2;
}
|