Determine the higher of 2 numbers

The following program has an error but I can't figure out what it is. The output should look like this:
Welcome to Minimum and Maximum!
Enter the first number:
3
Enter the second number:
4
The number 3 is lower than 4.
Program ended with exit code: 0

But instead I keep getting O in the final statement. Please help!!

#include <iostream>
using namespace std;
#define _USE_MATH_DEFINES ;
#include <cmath>

int main() {
double input1;
double input2;
double minimumValue;
double maximumValue;
cout <<"Welcome to Minimum and Maximum!\n";
cout <<"Enter the first number:\n";
cin >> input1;
cout <<"Enter the second number:\n";
cin >> input2;
fmin(minimumValue,maximumValue);
fmax(minimumValue,maximumValue);
cout <<"The number " << minimumValue << " is lower than " << maximumValue << "." ;
cout << endl;
return 0;
}
Last edited on
Can you explain what the fmin and fmax do?

What are the input1 and input2 for?
you are callin fmin and fmax with uninitialized data. They look like they should be taking input 1 and input 2 instead... else GIGO.

consider not even using functions for this.

max = min = input1;
if (min > input2) min = input2;
if (max < input2) max = input2;
cout << "..." << min << "..." << max << "..." << endl;
Topic archived. No new replies allowed.