If/else sorting problem

I posted in this forum a few days ago about a program I was having trouble with.
"A user enters 3 numbers, the program will sort the 3 numbers in ascending order and descending order, displaying both orders to the user. Only use if and else statements, no arrays,or anything else.

So i figured out how to code this, but it only works in certain instances.
if i enter single digit numbers in the order of 1,3,2 the program sorts it in the correct order with no problems. However if I start entering larger numbers in the order of 1000,700,950 for example. My program completely skips the second number. Why is this?

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
56
57
58
59
60
61
62
63
64
65
66
67
68
  #include <iostream>
#include <iomanip>

using namespace std;

int main()
{
	double numOne = 0.0;
	double numTwo = 0.0;
	double numThree = 0.0;
	double First = 0.0;
	double Second = 0.0;
	double Third = 0.0;

	cout << "Enter your first number: " << endl;
	cin >> numOne;

	cout << "Enter you second number: " << endl;
	cin >> numTwo;

	cout << "Enter you third number: " << endl;
	cin >> numThree;


	if ((numOne < numTwo) && (numOne < numThree)) 
		First = numOne;

	else if ((numTwo < numOne) && (numTwo < numThree))
		First = numTwo;

	else
		First = numThree;

	if ((numOne < numThree) && (numOne > numTwo))
		Second = numOne;
	else if ((numTwo < numThree) && (numTwo > numOne))
		Second = numTwo;
	else
		Second = numThree;


	

	if ((numOne > numTwo) && (numOne > numThree))
		Third = numThree;
	else if ((numTwo > numOne) && (numTwo > numThree))
		Third = numTwo;
	else
		Third = numThree;

	

	cout << "This is the ascending order" << endl;
	cout << "The first number is: " << First << endl;
	cout << "The second number is: " << Second << endl;
	cout << "The third number is: " << Third << endl;
	cout << " " << endl;

	cout << "This is the descending order" << endl;
	cout << "The third number is: " << Third << endl;
	cout << "The second number is: " << Second << endl;
	cout << "The First number is: " << First << endl;

	

	system("pause");
	return 0;
}//end of main function 
check out lines 44--45.

Also, you ignore some cases when calculating the second number.
For example, c < a < b
Topic archived. No new replies allowed.