Thread: C Program Roman Numerals to Numbers HELP!

  1. #1
    Registered User
    Join Date
    May 2014
    Posts
    1

    Red face C Program Roman Numerals to Numbers HELP!

    Hi Guys,
    I am very interested in C programming but unfortunately I'm not very smart and not very good at C programming either...

    I'm quite new to this, so would really appreciate it if someone would help me with this.

    So I have a fascination with Roman numerals and would like to create a C program that converts Roman numeral inputs to normal numbers.

    I want to keep everything simple and only use the C library for the coding.

    Can anybody give me some hints and help me with this?

    Thanks

    Chipped Dud

  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
    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
    Registered User Alpo's Avatar
    Join Date
    Apr 2014
    Posts
    877
    By the way, you don't really have to be super smart to get good at code. Though the idea probably protects a few egos or makes jobs more secure somewhere. All you have to be able to do is to plan well, and have a decent ability to visualize concepts.

  4. #4
    Registered User
    Join Date
    May 2014
    Posts
    5
    Quote Originally Posted by chipped_dud View Post
    So I have a fascination with Roman numerals and would like to create a C program that converts Roman numeral inputs to normal numbers.
    It's easily done using modular and integer division.

    First of all you need to understand how to convert decimal numbers into roman numerals.

    For instance, 1986 in roman numerals is MCMLXXXVI

    If you broke that down into thousands, hundreds, tens, and ones you'd get:

    1000 + 900 + 80 + 6 or 1-thousand, 9-hundreds, 8-tens, and 6-ones

    and if you convert each individually you'd end up with

    M + CM + LXXX + VI

    Note that 900 is not CCCCCCCCC nor is it DCCCC. A general rule for roman numerals is that no "digit" repeats more than three times and digits are in order of highest to lowest. When you have a lower digit in front of a higher digit, it subtracts. 400 becomes CD, 900 becomes CM, 4 becomes IV, 9 becomes IX, etc. 1990 would be MCMXC.

    With those general rules in mind it should be a snap to use modular and integer division with perhaps case statements, using some cases with breaks, some without (drop-down).

    Good luck.

  5. #5
    Registered User Alpo's Avatar
    Join Date
    Apr 2014
    Posts
    877
    Nevermind, I wrote a function, but it didn't actually work correctly because I had forgotten how roman numerals were written.
    Last edited by Alpo; 05-04-2014 at 11:04 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do i display a roman numerals from ordinary numbers??
    By Carr Paulo in forum C++ Programming
    Replies: 36
    Last Post: 07-07-2011, 09:38 PM
  2. help me in converting ordinary numbers to roman numerals..
    By Carr Paulo in forum C++ Programming
    Replies: 4
    Last Post: 07-05-2011, 07:15 AM
  3. Write a program to interpret roman numerals
    By unwanted in forum C Programming
    Replies: 2
    Last Post: 03-02-2011, 08:33 AM
  4. Replies: 3
    Last Post: 08-21-2006, 06:42 AM
  5. Making roman numerals into arabic numbers
    By Mule in forum C++ Programming
    Replies: 2
    Last Post: 04-12-2003, 11:35 PM

Tags for this Thread