C program to Convert Decimal Number into Roman Number

C program to Convert Decimal Number into Roman Number : Roman numerals, the numeric system in ancient Rome, uses combinations of letters from the Latin alphabet to signify values. There are several ways of representing the roman numbers say 4 decimal number can be represented as IV or IIII. But as per standardization of Roman Numbers IV is valid and accepted by Mathematicians as better way to represent it. Cost cutting is always being a fashion and been adapted by all, same happens in case of Roman Numbers. Lesser number of digits representation is considered as better.

The Romans used a special method of showing numbers, based on the following symbols:

1

5

10

50

100

500

1000

I

V

X

L

C

D

M

.

Now there are few rules that are being followed by modern age representatives :

1. A number written in Decimal numerals can be broken into digits. For example, 1903 is composed of 1, 9, 0, and 3. To write the Roman numeral, each of the non-zero digits should be treated separately. In the above example, 1,000 = M, 900 = CM, and 3 = III. Therefore, 1903 = MCMIII.

2. The symbols “I”, “X”, “C”, and “M” can be repeated three times in succession, but no more. (They may appear more than three times if they appear non-sequentially, such as XXXIX.) “D”, “L”, and “V” can never be repeated.

3. “I” can be subtracted from “V” and “X” only. “X” can be subtracted from “L” and “C” only. “C” can be subtracted from “D” and “M” only. “V”, “L”, and “D” can never be subtracted.

Numbers greater than 1,000 are formed by placing a dash over the symbol, meaning “times 1,000”, but these are not commonly used:

5,000

10,000

50,000

100,000

500,000

1,000,000

_

V

_

X

_

L

_

C

_

D

_

M

.

I have also avoided the same in the below C program. So there is one conflict in below program that it repeats M as many as times the thousands are there. I will update the modern Large Roman number logic in my next article about Roman number conversion.

By considering all above rule, let us see how to write a C program to convert Decimal number into Roman Number which take decimal number as input of the program and displays the equivalent Roman number.

Well, I am software programmer and love to code. My hobbies is to do Hacking, Coding, Blogging, Web Designing and playing online games.
Feel free to contact me at shiviskingg@gmail.com or lokesh@hackingloops.com

7 COMMENTS

dear sir ,,,
i tried using ur code in my turbo c++ 3.0…..
i wanted to convert decimal number to roman
but when i compiled and executed
it is printing only invalid number…in the out put
plz kindly solve this problem