Convert integer to roman numeral function

I need to create a function to convert an integer to a roman numeral, this is what I have so far.



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
  int main() {
    
    void Roman(int nu,int  m, int d, int c, int l, int x,int  v,int  i, int  n)
    {
        double num;
        
        
        if (nu >= 1000)
        {
            m = n / 1000;
            n = 0;
            {
                for (n; n < m; n++)
                    cout << "M";
            }
            nu = nu % 1000;
        }
        
        else if (nu >= 900)
        {
            cout << "DCCCC";
            n = n % 900;
        }
        else if (nu >= 500)
        {
            {
                d = nu / 500;
                n = 0;
                for (n; n < d; n++)
                    cout << "D";
            }
            nu = nu % 500;
        }
        
        if (nu >= 400)
        {
            cout << "CD";
            nu = nu % 400;
        }
        else if (nu >= 100)
        {
            {
                c = nu / 100;
                n = 0;
                for (n; n < c; n++)
                    cout << "C";
            }
            nu = nu % 100;
        }
        
        if (nu >= 90)
        {
            cout << "XC";
            nu = nu % 90;
        }
        
        else if (nu >= 50)
        {
            {
                l = intnum / 50;
                n = 0;
                for (n; n < l; n++)
                    cout << "L";
            }
            nu = nu % 50;
        }
        if (nu >= 40)
        {
            cout << "XL";
            nu = nu % 40;
        }
        
        else if (nu >= 10)
        {
            {
                x = nu  / 10;
                n = 0;
                for (n; n < x; n++)
                    cout << "X";
            }
            nu = nu % 10;
        }
        
        if (nu >= 9)
        {
            cout << "VIIII";
            nu = nu  % 9;
        }
        
        else if (nu >= 5)
        {
            {
                v = nu / 5;
                n = 0;
                for (n; n < v; n++)
                    cout << "V";
            }
            nu = nu % 5;
        }
        if (nu  >= 4)
        {
            cout << "IIII";
            nu = nu % 4;
        }
        else if (nu  >= 1)
        {
            i = nu;
            n = 0;
            for (n; n < i; n++)
                cout << "I";
        }
   
    return 0;
}


I just don't know where to go from here, and I'm lost...
Line 3: You can't nest one function (Roman) inside another (main).

Line 5: What's the purpose of num? You don't reference it.

Line 3: Why are you passing m,d,c,l,x,i,n as arguments? These should be local variables inside Roman.

Line 112: You're missing a close brace for Roman.

Line 112: You need to call Roman passing it a number to convert.



Topic archived. No new replies allowed.