Having a problem comparing three numbers
My display is producing:
Enter the first number:234
Enter the second number:2
Enter the Third number:3
The largest number is 3
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
|
#include <iostream>
using namespace std;
double larger(double n1, double n2, double n3);
int main()
{
double num;
double max;
int count;
double num1, num2,num3;
cout<<"Enter the first number:";
cin>> num1;
cout<<"Enter the second number:";
cin>> num2;
cout<<"Enter the Third number:";
cin>> num3;
max = (num1, num2, num3);
cout << "The largest number is " << max
<< endl;
return 0;
}
double larger(double n1, double n2, double n3)
{
if (n1 > n2 && n1 > n3)
return n1;
else if (n2 > n3)
return n2;
else
return n3;
}
| |
Line 23 should be
|
max = larger(num1, num2, num3);
| |
Topic archived. No new replies allowed.