# Roman Numerals

• 11-23-2009
jfrizzy
Roman Numerals
Hello,
I have an assignment to write a program in C to convert a numerical year into a Roman numeral. I have been messing with it for about a week and I'm stuck on where to start and how to go about doing it. If any one could help me get started or throw out a few idea os pseudocodes to get me on the right track I would appreciate it.
Thanks.
• 11-23-2009
itCbitC
Write out the decimal number in terms of place-value notation ie thousandths, hundreds, tens, and units digits.
Now convert each of those constituent digits to its equivalent Roman numeral:

Year 1995 == 1000 (M) + 900 (CM) + 90 (XC) + 5 (V) --> "MCMXCV"
Year 1989 == 1000 (M) + 900 (CM) + 80 (LXXX) + 9 (IX) --> "MCMLXXXIX"
• 11-23-2009
jfrizzy
Roman
I started with this now I'm scratching my head wondering how to turn the 1's and 2' etc. into M,C,D,L,X,V, and I. I may have went at this the wrong way but I dont know. I figured I would error check the exceptions (ie IV, IX, XL, CM, etc.) later in for or do while loops. Any ideas on whether I ma going about this the right way, and maybee where to go with it so it makes sence, would greatly be appreciated.

Code:

``` #include <stdio.h> #include<stdlib.h> #include <time.h> void main() {         int year;         int Roman;         int M;         int D;         int C;         int L;         int X;         int V;         int I;         int change[6];                                                 printf("Enter a year I'll convert it to its Roman Numeral Equivalent \n");                         scanf("%d", &year);                                                 M = year / 1000;                         change[0] = year%1000;                                                 D = change[0] / 500;                         change[1]= change[0]%500;                                                 C = change[1] / 100;                         change[2] = change[1]%100;                                                 L = change[2] / 50;                         change[3] = change[2] % 50;                                                 X = change[3] / 10;                         change[4] = change[3] % 10;                                                 V = change[4] / 5;                         change[5] = change[4] % 5;                                                 I = change[5] / 1;                                                 }```