The following code outputs the second number as the maximum. If you need any other information please let me know.
#include <iostream>
#include <cstdlib>
using namespace std;
double *ComputeMaximum(const double *Max, const double *Min);
double *ComputeMaximum(const double *Max, const double *Min)
{
return ((double *)((&Max > &Min) ? Max : Min));
}
int main(void)
{
double *max;
double Initial, Secondary;
cout << "Enter the number followed by space then another number: ";
cin >> Initial;
cout << "\nIn-" << Initial;
cin >> Secondary;
cout << "\nSe-" << Secondary;
//cout >> "Of " >> Inital >> "and " >> Secondary;
//cout >> "the maximum is " >>
max = ComputeMaximum((double*)&Initial,(double*)&Secondary);
cout << "\nmax" << *max;
return 0;
}
The next code outputs the first number as the maximum
#include <iostream>
#include <cstdlib>
using namespace std;
double *ComputeMaximum(const double *Max, const double *Min);
double *ComputeMaximum(const double *Max, const double *Min)
{
return ((double *)((Max > Min) ? Max : Min)); // Here is the difference(& missing)
}
int main(void)
{
double *max;
double Initial, Secondary;
cout << "Enter the number followed by space then another number: ";
cin >> Initial;
cout << "\nIn-" << Initial;
cin >> Secondary;
cout << "\nSe-" << Secondary;
//cout >> "Of " >> Inital >> "and " >> Secondary;
//cout >> "the maximum is " >>
max = ComputeMaximum((double*)&Initial,(double*)&Secondary);
cout << "\nmax" << *max;
return 0;
}
What is being done wrong? I only need the maximum, not the second or first input. I got the answer. Thank YOu all.
Here it is:
#include <iostream>
#include <cstdlib>
using namespace std;
double *ComputeMaximum(const double *Max, const double *Min);
double *ComputeMaximum(const double *Max, const double *Min)
{
return (double*)((*Max > *Min) ? Max : Min);
}
int main(void)
{
double *max;
double Initial, Secondary;
cout << "Enter the number followed by space then another number: ";
cin >> Initial;
cout << "\nIn-" << Initial;
cin >> Secondary;
cout << "\nSe-" << Secondary;
//cout >> "Of " >> Inital >> "and " >> Secondary;
//cout >> "the maximum is " >>
max = ComputeMaximum(&Initial, &Secondary);
cout << "\nmax" << *max;
return 0;
}