sort integers using if-else

I wrote this code to sort 3 integers but I can't figure out how to add a 4th. The program is supposed to sort 4 integers using only if-else statements (no loops).
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
#include <iostream>

using namespace std;

int main ()
{
    cout << "Enter 4 integers: ";
	int a, b, c, d;
	
	cin >> a >> b >> c >> d;
	
	if (a<b)
	{
		if (b<c)
		{
			cout << a << b << c << endl;
		}
		else if (a<c)
		{
			cout << a << c << b << endl;
		}
		else cout << c << a << b << endl;
	}
	
	else if (b<c)
	{
		if (c<a)
		{
			cout << b << c << a << endl;
		}
		else if (b<a)
		{
			cout << b << a << c << endl;
		}
		else cout << a << b << c << endl;
	}
	
	else if (c<a)
	{
		if (a<b)
		{
			cout << c << a << b << endl;
		}
		else if (c<b)
		{
			cout << c << b << a << endl;
		}
		else cout << b << c << a << endl;
	}
	
	else 
	{
		cout << a << b << c << d;
	}

    return 0;
}
well....if the number if integer increase, so does if-else statements....so get bak to your coding and start coding!!! :)
Topic archived. No new replies allowed.