# Thread: Code converting decimal numbers to Roman nomerals

1. ## Code converting decimal numbers to Roman nomerals

I write this code, but it doesn`t work and i don`t understand why

Code:
```#include<stdio.h>

int main(void) {
int decimal[] = { 1000,900,500,400,100,90,50,40,10,9,5,4,1 }; //base values
char symbol[] = { 'M','CM','D','CD','C','XC','L','XL','X','IX','V','IV','I' };  //roman symbols
int i = 0, num;

printf("Enter a number: \n");
scanf_s("%d", &num);
printf("The Roman numeral is: \n");
while (num != 0) {                               //repeat process until num is not 0
if (num / decimal[i]) {              //first base value that divides num is largest base value
printf("%s", symbol[i]);            //print roman symbol equivalent to largest base value
num -= decimal[i];                  //subtract largest base value from num
}
i++;                                    //move to next base value to divide num
}
return 0;
}```

2. > 'CM'
You need to express these as strings, not as wide character constants.

So "CM" not 'CM'

Note that something like 300 would be printed out as "CCC", but your code doesn't take that into account.

3. Originally Posted by Salem
> 'CM'
You need to express these as strings, not as wide character constants.

So "CM" not 'CM'

Note that something like 300 would be printed out as "CCC", but your code doesn't take that into account.
If I write "CM" for example, visual studio say that it`s error(

4. Mmmm
Code:
```const char *symbol[] = {
"M",
// etc
};```

5. Ooh, thanks it works