Thread: how do i display a roman numerals from ordinary numbers??

  1. #16
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    So do you want to do this in C (which is the code you posted) or C++?
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  2. #17
    Registered User
    Join Date
    Jul 2011
    Posts
    15
    yes!! c++..sorry for some wrong doing i am doing that only says to you that i am only a beginner in terms of this area..or forum..

  3. #18
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Ordinary Numbers = Roman Numerals
    1=I
    5=V
    10=X
    50=L
    100=C
    500=D
    100=M
    I never understood the massive confusion that surrounds Roman numerals and using them. Proper Roman numerals are always arranged from greatest to least so conversion is simply done by computing from left to right. If a number or group of numbers is smaller than its neighbor then you have to subtract the left thing from the right thing in the sum. There is no standardization. XXCIII is as correct as LXXXIII is for 83, so sanitizing is kind of pointless.

  4. #19
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    Ordinary Numbers = Roman Numerals
    1=I
    5=V
    10=X
    50=L
    100=C
    500=D
    1000=M
    But yes, your point about non-standardization is spot on.

  5. #20
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Quote Originally Posted by Carr Paulo View Post
    yes!! c++..sorry for some wrong doing i am doing that only says to you that i am only a beginner in terms of this area..or forum..
    Does this look like something you know?
    Code:
    #include <iostream>
    
    using namespace std;
    
    int main(){
    
       cout << "Hello world";
    
       return (0);
    }
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  6. #21
    Registered User
    Join Date
    Jul 2011
    Posts
    15
    yeahh.it is easy in terms of coverting it..ahmmm plase mr.kindly my actual problem on the very beginning of the first page...thank you hope you understand what i want to say..thank you/

  7. #22
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    my problem is this...please help. i need a algorithm and solution,,
    Step 1: Is the input greater than the largest Roman numeral?

    If not, then the very first numeral is not 'M'. If so, then the very first numeral is 'M'.

  8. #23
    Registered User
    Join Date
    Jul 2011
    Posts
    15
    mr.andrew the code that you posted i am not familiar on that kind of code..like i said i am only familiar in a header files..stdio.h and conio.h.

    and i ahm only using the (int)as a variable declaration..

    i i am only familiar with a code ending in getch; and }..

  9. #24
    Registered User
    Join Date
    Jul 2011
    Posts
    15
    no! my input data must:

    "Iput a number to be converted:"

    and as i result i will output it in form of roman numeral.

    my problem is to convert the number to a roman numeral..with a no.input of a 3000 capacity.

  10. #25
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    Yes!

    Step 1: Is the input greater than the largest Roman numeral? <----- Input number to be converted!

    If not, then the very first numeral is not 'M'. If so, then the very first numeral is 'M'. <----- Output in the form of a Roman numeral!

  11. #26
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    If numbers in Roman numerals are arranged from greatest to least it stands to reason that writing Roman numerals is just about taking the biggest chunks you can out of numbers.

    Find out which of the biggest denominations you can start with and write it. Usually this means you can concentrate on each place value at once.

    1984 is more than 1000. Write the letter M. Convert 984 next.
    984 is less than 1000 but more than 500 so write D. Convert 484 next.
    484 is less than 500 but more than one hundred. If we stick to the plan, we can convert a single place value. 4 Cs make up 400. Convert 84.
    80 is more than 50, so write L, then convert 34.
    30 is XXX. Convert 4.
    Now we come to single digits which you should probably just have saved for lookup. 4 is IV.

    You might end up with loooong numbers, but this is why we use Arabic.

  12. #27
    Registered User
    Join Date
    Jul 2011
    Posts
    15
    i cant get your point mr.matticus..am for us to communicate well..refer to my example..

    when i input: 1000
    the output must be: M

    if i input:3000
    then the output is:MMM

    if i input 1
    the output must be I

    and i input 9
    the out put must be IX..


    _when ever i input..it mus output it equivalent roman numerals..my point is what formula i will do..when it comes in 9,111,11,3,4,1002,etc,,....

    if only the numbers to be input is on the chart. it is easy..because i will only write the formula

    example//
    if(n(variable declaration as input value)==1)
    prinf(The roman is: I);
    else if(n==1000)
    printf("The Roman is:M");

    but how if the input is 9??
    how i output it as IX??what formula i will do to ouput it??
    do i need to ennumerate it all from 1 to 3000??

  13. #28
    Registered User
    Join Date
    Apr 2006
    Posts
    2,149
    Well the usual standard is to have no more than than 3 consecutive digits added, so that XXX is 30, XL is 40, LXXX is 80, and XC is 90. But that just adds a few extra steps.

    It's up to the OP and his instructor whether or not to apply that standard.

    Converting the other way it would make sense to allow more liberal ordering.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  14. #29
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    WhiteFlags gave you really good advice, much better than mine. You should read that thoroughly, it should answer your question.

  15. #30
    Registered User
    Join Date
    Jul 2011
    Posts
    15
    yes..i thought that your getting what i mean whiteflags??then what kind of operators i will use..??when i write a algorithm flowchart and solution..can you give a example code??when converting 9??i will use it as a guidelines..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Roman Numerals
    By jfrizzy in forum C Programming
    Replies: 2
    Last Post: 11-23-2009, 07:43 PM
  2. integers to roman numerals(beginner)
    By FragileWarning1 in forum C++ Programming
    Replies: 2
    Last Post: 03-31-2007, 01:38 PM
  3. converting arabic to roman numerals
    By kaisha8 in forum C++ Programming
    Replies: 2
    Last Post: 09-26-2004, 01:02 AM
  4. Making roman numerals into arabic numbers
    By Mule in forum C++ Programming
    Replies: 2
    Last Post: 04-12-2003, 11:35 PM
  5. Need help with Roman Numerals
    By kiddprogrammer in forum C Programming
    Replies: 6
    Last Post: 04-01-2003, 11:45 PM