Hi
When I enter the value of A to be, say, "b", the output given below is what I get. But I was expecting it to return "Input error" because this is what I mentioned in the "else" statement. Where am I going wrong? Please guide me on this and please don't forget I'm newbie to this programming world! Thanks a lot.
OUTPUT:
Code:
enter the numbers A, B, C
enter A = b
enter B = enter C = the ascending order is 2.8026e-045 9.52883e-044 3.21412e-039
Press any key to continue . . .
Code:
/* arranging the three numbers in ascending order assuming the numbers
are distinct */
// there would be six permutations in total
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
float A, B, C;
cout << "enter the numbers A, B, C" << endl ;
cout << "enter A = " ;
cin >> A;
cout << "enter B = " ;
cin >> B;
cout << "enter C = " ;
cin >> C;
{
if ( (A < B) && (B < C) )
cout << "the ascending order is " << A << '|' << B << '|' << C << endl;
else if ( (A < C) && (C < B) )
cout << "the ascending order is " << A << '|' << C << '|' << B << endl;
else if ( (B < A) && (A < C) )
cout << "the ascending order is " << B << '|' << A << '|' << C << endl;
else if ( (B < C) && (C < A) )
cout << "the ascending order is " << B << '|' << C << '|' << A << endl;
else if ( (C < A) && (A < B) )
cout << "the ascending order is " << C << '|' << A << '|' << B << endl;
else if ( (C < B) && (B < A) )
cout << "the ascending order is " << C << '|' << B << '|' << A
<< endl;
else
cout << "Input error" << endl;
}
system("pause");
}