Help with reducing number of loops & if statements

I need to create a program where given an integer n (input from the user), the program determines the equivalent of n in the roman numeral system. The user will provide a value of n greater than 0 and less than 4000.

the solution must use

* 1 or 2 loops at most
* 1, 2, 3 or 4 switch instructions at most, and each switch can have up to 5 cases, including the default case
* less than 11 if statements
* no strings!!

I used this code however there are too many loops and if statements how could i reduce it to fit the requirements
thank you

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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include <iostream>
using namespace std;



int main()
{


double n;
int intn, m, d, c, l, x, v, i, p;


cout << "Enter n ";
cin >> n;
intn = (int)n;


if (intn >= 1000)
{
    m = intn / 1000;
    n = 0;
		{
		for (p; p < m; p++)
		cout << "M";
		}
	intn = intn%1000;
}


if (intn >= 900)
{
	cout << "CM";
	intn = intn%900;
}
	else if (intn >= 500)
    {
			{
			d = intn / 500;
			p = 0;
			for (p; p < d; p++)
			cout << "D";
			}
        intn = intn%500;
    }


if (intn >= 400)
{
	cout << "CD";
	intn = intn%400;
}
    else if (intn >= 100)
	{
		    {
            c = intn / 100;
            p = 0;
            for (p; p < c; p++)
            cout << "C";
			}
		intn = intn%100;
	}


if (intn >= 90)
{
cout << "XC";
intn = intn%90;
}


	else if (intn >= 50)
	{
			{
            l = intn / 50;
			p = 0;
            for (p; p < l; p++)
            cout << "L";
			}
		intn = intn%50;
	}
if (intn >= 40)
{
cout << "XL";
intn = intn%40;
}


	else if (intn >= 10)
	{
			{
            x = intn / 10;
            p = 0;
            for (p; p < x; p++)
            cout << "X";
			}
		intn = intn%10;
	}


if (intn >= 9)
{
cout << "IX";
intn = intn%9;
}


	else if (intn >= 5)
	{
			{
            v = intn / 5;
            p = 0;
            for (p; p < v; p++)
            cout << "V";
			}
		intn = intn%5;
	}
if (intn >= 4)
{
cout << "IV";
intn = intn%4;
}
	else if (intn >= 1)
	{
           i = intn;
           p = 0;
           for (p; p < i; p++)
           cout << "I";
	}




return 0;


}
Topic archived. No new replies allowed.