How can i make a program that converts Arabic Numbers to Roman Numbers. From 1-3999. Please help me.
How can i make a program that converts Arabic Numbers to Roman Numbers. From 1-3999. Please help me.
You could try searching the board.
You'll need to know how "%" works. For example, this would work on 1-5:
n % 5 returns the remainder of n / 5.Code:switch(n % 5)
{
case 0:
printf("V");
break;
case 1:
printf("I");
break;
case 2:
printf("II");
break;
case 3:
printf("III");
break;
case 4:
printf("IV");
break;
}
Google algorithms for this, because I had to do this in Lisp or Haskell or Prolog (one of those useless languages) for my Programming Language Concepts course (I believe it was Lisp, but it was a year ago). So there's definitely algorithms out on the web, I found some just by googling it.
Just google something along the lines of:
program latin number roman
Switch statements are the best, here. Your best bet is to dissect the number and go through it piece by piece.
EDIT:
PS: Make sure you have a thorough understanding of the Roman Numeral System before hitting this up, sure, 1-20 is easy, but make sure you understand the rest pretty thoroughly, take a trip over to the roman numeral wikipedia. I knew I got tripped up by some of the higher numbers and it cost me a decent bit of time until I figured out some issues while working against the higher values.