answersLogoWhite

0

I can't speak about C, but I imagine that it is similar process to Visual Basic or HyperCard.

Roman numerals are not "place dependent" so you need to write a repeating loop which will cycle through the individual characters of the string and add their value to a variable, 100 for C, 10 for X and so on, and at the end of the loop display the variable. Start the variable with a value of 0 and then it will increase as you process each character.

-----

Not strictly true, as using the above method IV would give 6 instead of 4.

You would need to loop from right to left, adding up the individual characters.

But if an individual character has a lower value than the character to its right, you would need to subtract instead of add.

e.g.

XIV = 5 - 1 + 10 = 14

MCM = 1000 - 100 + 1000 = 1900

XVII = 1 + 1 + 5 + 10 = 17

User Avatar

Wiki User

15y ago

What else can I help you with?