Thread: How can i make a program that converts Arabic Numbers to Roman Numbers

  1. #1
    Registered User
    Join Date
    Sep 2010
    Posts
    1

    How can i make a program that converts Arabic Numbers to Roman Numbers

    How can i make a program that converts Arabic Numbers to Roman Numbers. From 1-3999. Please help me.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    You could try searching the board.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Password:
    Join Date
    Dec 2009
    Location
    NC
    Posts
    587
    You'll need to know how "%" works. For example, this would work on 1-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;
    }
    n % 5 returns the remainder of n / 5.

  4. #4
    Registered User
    Join Date
    Aug 2010
    Location
    Rochester, NY
    Posts
    196
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. roman to arabic and vise versa
    By tm` in forum C Programming
    Replies: 2
    Last Post: 12-14-2007, 08:28 AM
  2. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  3. A very long list of questions... maybe to long...
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-16-2007, 05:36 AM
  4. want to make this small program...
    By psycho88 in forum C++ Programming
    Replies: 8
    Last Post: 11-30-2005, 02:05 AM
  5. Making roman numerals into arabic numbers
    By Mule in forum C++ Programming
    Replies: 2
    Last Post: 04-12-2003, 11:35 PM