Decimal to Roman Numerals

Discussion in 'C Programming' started by ARMAS, Jan 24, 2007.

  1. ARMAS

    ARMAS Guest

    Make a program that allows the user to input a number and aoutput it's
    roman numeral equivalent..... plzzzzzz help....
    Ex: 109 output:CIX
    ARMAS, Jan 24, 2007
    #1
    1. Advertising

  2. ARMAS

    Lew Pitcher Guest

    On Jan 23, 8:36 pm, "ARMAS" <> wrote:
    > Make a program that allows the user to input a number and aoutput it's
    > roman numeral equivalent..... plzzzzzz help....
    > Ex: 109 output:CIX


    OK, show us what you've got so far, and we'll make suggestions
    Lew Pitcher, Jan 24, 2007
    #2
    1. Advertising

  3. ARMAS

    ARMAS Guest

    On Jan 24, 9:40 am, "Lew Pitcher" <> wrote:
    > On Jan 23, 8:36 pm, "ARMAS" <> wrote:
    >
    > > Make a program that allows the user to input a number and aoutput it's
    > > roman numeral equivalent..... plzzzzzz help....
    > > Ex: 109 output:CIXOK, show us what you've got so far, and we'll make suggestions


    I have no idea .... i'm just a feshmen.... maybe i could try but it
    wil take me a long time... and i need a quick answer... plzzzz
    ARMAS, Jan 24, 2007
    #3
  4. ARMAS

    user923005 Guest

    On Jan 23, 5:43 pm, "ARMAS" <> wrote:
    > On Jan 24, 9:40 am, "Lew Pitcher" <> wrote:
    >
    > > On Jan 23, 8:36 pm, "ARMAS" <> wrote:

    >
    > > > Make a program that allows the user to input a number and aoutput it's
    > > > roman numeral equivalent..... plzzzzzz help....
    > > > Ex: 109 output:CIXOK, show us what you've got so far, and we'll make suggestionsI have no idea .... i'm just a feshmen.... maybe i could try but it

    > wil take me a long time... and i need a quick answer... plzzzz


    Quck answer:
    DYOH!
    user923005, Jan 24, 2007
    #4
  5. ARMAS

    ARMAS Guest

    On Jan 24, 9:54 am, "user923005" <> wrote:
    > On Jan 23, 5:43 pm, "ARMAS" <> wrote:
    >
    > > On Jan 24, 9:40 am, "Lew Pitcher" <> wrote:

    >
    > > > On Jan 23, 8:36 pm, "ARMAS" <> wrote:

    >
    > > > > Make a program that allows the user to input a number and aoutput it's
    > > > > roman numeral equivalent..... plzzzzzz help....
    > > > > Ex: 109 output:CIXOK, show us what you've got so far, and we'll make suggestionsI have no idea .... i'm just a feshmen.... maybe i could try but it

    > > wil take me a long time... and i need a quick answer... plzzzzQuck answer:

    > DYOH!


    >>I'm asking for help, not a bullshit answer
    ARMAS, Jan 24, 2007
    #5
  6. ARMAS

    user923005 Guest

    > >>I'm asking for help, not a bullshit answer

    That is where you are wrong (in both regards).
    You are not asking for help. You are asking for someone to do your
    homework for you. That is decidedly not helpful for your future but
    harmful.
    Because of your attitude, I am sure that any code answer you receive
    will be rather humorous.
    user923005, Jan 24, 2007
    #6
  7. ARMAS

    ARMAS Guest

    On Jan 24, 10:15 am, "user923005" <> wrote:
    > > >>I'm asking for help, not a bullshit answerThat is where you are wrong (in both regards).

    > You are not asking for help. You are asking for someone to do your
    > homework for you. That is decidedly not helpful for your future but
    > harmful.
    > Because of your attitude, I am sure that any code answer you receive
    > will be rather humorous.



    It ain't a homework....
    ARMAS, Jan 24, 2007
    #7
  8. "ARMAS" <> writes:
    > On Jan 24, 9:54 am, "user923005" <> wrote:
    > > On Jan 23, 5:43 pm, "ARMAS" <> wrote:
    > >
    > > > On Jan 24, 9:40 am, "Lew Pitcher" <> wrote:

    > >
    > > > > On Jan 23, 8:36 pm, "ARMAS" <> wrote:

    > >
    > > > > > Make a program that allows the user to input a number and aoutput it's
    > > > > > roman numeral equivalent..... plzzzzzz help....
    > > > > > Ex: 109 output:CIXOK, show us what you've got so far, and we'll make suggestionsI have no idea .... i'm just a feshmen.... maybe i could try but it
    > > > wil take me a long time... and i need a quick answer... plzzzzQuck answer:

    > > DYOH!

    >
    > >>I'm asking for help, not a bullshit answer


    No, you're asking us to do your homework for you.

    If you're unable to do it yourself, we'd prefer that you fail the
    class.

    If you want *help*, we might be able to provide some, but we're not
    going to do it all for you.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
    Keith Thompson, Jan 24, 2007
    #8
  9. ARMAS

    user923005 Guest

    /*
    Since we know it's not for school but he just needs this to do his
    important work,
    I decided to write a nice converter for him. Enjoy:
    */
    #include<stdio.h>
    #include<stdlib.h>
    int main(int q0,char*q1??(??))??<long q2,q3;int q4=1;typedef struct q5
    ??<int q6;char*q7;int q8;char*q9;??>q10;q10 q11??(??)=??<
    #ifdef q12
    ??<1000000,"\74\115\55\142\141\162\76",900000,
    "\74\103\115\55\142\141\162\76"??>,??<500000,
    "\74\104\55\142\141\162\76",400000,"\74\103\104\55\142\141\162\
    \76"??>,??<100000,"\74\103\55\142\141\162\76",90000,
    "\74\130\103\55\142\141\162\76"??>,??<50000,
    "\74\114\55\142\141\162\76",40000,"\74\130\114\55\142\141\162\
    \76"??>,??<10000,"\74\130\55\142\141\162\76",9000,
    "\74\111\130\55\142\141\162\76"??>,??<5000,"\74\126\55\142\141\162\76"
    ,4000,"\74\111\126\55\142\141\162\76"??>,
    #endif
    ??<1000,"\115",900,"\103\115"??>,??<500,"\104",400,"\103\104"??>,??<
    100,"\103",90,"\130\103"??>,??<50,"\114",40,"\130\114"??>,??<10,"\130"
    ,9,"\111\130"??>,??<5,"\126",4,"\111\126"??>,??<1,"\111",1,"\111"??>
    ??>;int q13=0;if(q0==2)q2=atol(q1??(1??));else??<if(q0==3)??<q2=atol(
    q1??(1??));q4=0;??>else??<printf("\n\105\156\164\145\162\40\141\156\40"
    "\151\156\164\145\147\145\162\40\166\141\154\165\145\72\40"
    );scanf("\45\154\144",&q2);??>??>q3=q2;printf("\n\45\154\144\40\75\40"
    ,q3);do??<while(q2>=q11??(q13??).q6)??<printf("\45\163",q11??(q13??).
    q7);q2-=q11??(q13??).q6;??>if(q4)if(q2>=q11??(q13??).q8)??<printf(
    "\45\163",q11??(q13??).q9);q2-=q11??(q13??).q8;??>q13++;??>while(q2>0)
    ;return(0);??>
    user923005, Jan 24, 2007
    #9
  10. "ARMAS" <> wrote in message
    news:...
    >
    >
    > On Jan 24, 9:40 am, "Lew Pitcher" <> wrote:
    >> On Jan 23, 8:36 pm, "ARMAS" <> wrote:
    >>
    >> > Make a program that allows the user to input a number and aoutput it's
    >> > roman numeral equivalent..... plzzzzzz help....
    >> > Ex: 109 output:CIXOK, show us what you've got so far, and we'll make
    >> > suggestions

    >
    > I have no idea .... i'm just a feshmen.... maybe i could try but it
    > wil take me a long time... and i need a quick answer... plzzzz


    There are these things called "books". You probably have not heard of them.
    They are in:

    a)Libraries.

    b)Bookstores.

    c)Other places.

    You may want to explore "books"; specifically a book about the 'C'
    programming language.

    When you have something resembling a program that you can't get to work,
    feel free to post back to this newsgroup.

    Also, if you want to hire me to do your program, I will do a "Roman Numeral"
    program for USD $1,500. That is probably about $25/line.

    There may be others in this newsgroup who will do it for less. I won't be
    hurt if you contract with one of them.

    --
    David T. Ashley ()
    http://www.e3ft.com (Consulting Home Page)
    http://www.dtashley.com (Personal Home Page)
    http://gpl.e3ft.com (GPL Publications and Projects)
    David T. Ashley, Jan 24, 2007
    #10
  11. ARMAS wrote:
    >
    > On Jan 24, 10:15 am, "user923005" <> wrote:
    > > > >>I'm asking for help, not a bullshit answerThat is where you are wrong (in both regards).

    > > You are not asking for help. You are asking for someone to do your
    > > homework for you. That is decidedly not helpful for your future but
    > > harmful.
    > > Because of your attitude, I am sure that any code answer you receive
    > > will be rather humorous.

    >
    > It ain't a homework....


    Then what is it? All available evidence says otherwise.

    Quoting your previous post:

    > i'm just a feshmen....


    Translation: I'm in school.

    > maybe i could try but it wil take me a long time...


    Translation: I'm lazy.

    > and i need a quick answer...


    Translation: The assignment is due tomorrow.

    You've also said you have "no idea" on how to do this. If that's
    the case, why are you doing this?

    Conclusion: It's homework.

    --
    +-------------------------+--------------------+-----------------------+
    | Kenneth J. Brody | www.hvcomputer.com | #include |
    | kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h> |
    +-------------------------+--------------------+-----------------------+
    Don't e-mail me at: <mailto:>
    Kenneth Brody, Jan 24, 2007
    #11
  12. In article <>,
    David T. Ashley <> wrote:

    >Also, if you want to hire me to do your program, I will do a "Roman Numeral"
    >program for USD $1,500. That is probably about $25/line.
    >
    >There may be others in this newsgroup who will do it for less. I won't be
    >hurt if you contract with one of them.


    No, no, you don't understand the way we do things here.

    Offers of contracts to do homework problems are traditionally done on a
    "highest bid" basis; the offer includes a clause that it is invalidated
    by anybody posting a higher offer to the thread in which it is made.

    I am willing to write a roman numeral converter for the OP for US$2000,
    payment in advance by certified check or money order. This offer is
    valid until midnight (UTC) this Friday, 2007-01-26, or until a higher
    offer is made, whichever comes sooner.


    dave

    --
    Dave Vandervies
    The ISO C Standard defines the truth in C. Therefore, it makes an excellent
    weapon to use in a fight.
    --Richard Heathfield in comp.lang.c
    Dave Vandervies, Jan 24, 2007
    #12
  13. (Dave Vandervies) writes:
    > In article <>,
    > David T. Ashley <> wrote:
    >
    > >Also, if you want to hire me to do your program, I will do a "Roman
    > >Numeral" program for USD $1,500. That is probably about $25/line.
    > >
    > >There may be others in this newsgroup who will do it for less. I won't be
    > >hurt if you contract with one of them.

    >
    > No, no, you don't understand the way we do things here.
    >
    > Offers of contracts to do homework problems are traditionally done on a
    > "highest bid" basis; the offer includes a clause that it is invalidated
    > by anybody posting a higher offer to the thread in which it is made.
    >
    > I am willing to write a roman numeral converter for the OP for US$2000,
    > payment in advance by certified check or money order. This offer is
    > valid until midnight (UTC) this Friday, 2007-01-26, or until a higher
    > offer is made, whichever comes sooner.


    Isn't it also traditional to offer a discount if the solution can be
    submitted directly to the instructor?

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
    Keith Thompson, Jan 24, 2007
    #13
  14. ARMAS <> wrote:

    > I have no idea .... i'm just a feshmen.... maybe i could try but it
    > wil take me a long time... and i need a quick answer... plzzzz


    Either try it yourself or accept that maybe you should have started
    this little project a little bit earlier. Plenty of freshmen before
    you have figured at least that much out, or possibly gone on to flip
    burgers. You still have a choice; I suggest you choose wisely.

    --
    C. Benson Manica | I *should* know what I'm talking about - if I
    cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
    Christopher Benson-Manica, Jan 24, 2007
    #14
  15. ARMAS

    user923005 Guest

    On Jan 23, 9:07 pm, Keith Thompson <> wrote:
    > (Dave Vandervies) writes:
    > > In article <>,
    > > David T. Ashley <> wrote:

    >
    > > >Also, if you want to hire me to do your program, I will do a "Roman
    > > >Numeral" program for USD $1,500. That is probably about $25/line.

    >
    > > >There may be others in this newsgroup who will do it for less. I won't be
    > > >hurt if you contract with one of them.

    >
    > > No, no, you don't understand the way we do things here.

    >
    > > Offers of contracts to do homework problems are traditionally done on a
    > > "highest bid" basis; the offer includes a clause that it is invalidated
    > > by anybody posting a higher offer to the thread in which it is made.

    >
    > > I am willing to write a roman numeral converter for the OP for US$2000,
    > > payment in advance by certified check or money order. This offer is
    > > valid until midnight (UTC) this Friday, 2007-01-26, or until a higher
    > > offer is made, whichever comes sooner.Isn't it also traditional to offer a discount if the solution can be

    > submitted directly to the instructor?


    I already posted a working solution (under conditional compilation it
    also uses the bar notation for huge roman numeral values) and thereby
    claim all prizes.
    I also get the grade, if it is above a C.
    However, getting tossed out on your ear for plagiarism I leave to the
    O.P. untouched and pristine.

    > --
    > Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    > San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    > We must do something. This is something. Therefore, we must do this.
    user923005, Jan 24, 2007
    #15
  16. ARMAS

    rsood Guest

    On Jan 24, 12:07 am, Keith Thompson <> wrote:
    > (Dave Vandervies) writes:
    > > In article <>,
    > > David T. Ashley <> wrote:

    >
    > > >Also, if you want to hire me to do your program, I will do a "Roman
    > > >Numeral" program for USD $1,500. That is probably about $25/line.

    >
    > > >There may be others in this newsgroup who will do it for less. I won't be
    > > >hurt if you contract with one of them.

    >
    > > No, no, you don't understand the way we do things here.

    >
    > > Offers of contracts to do homework problems are traditionally done on a
    > > "highest bid" basis; the offer includes a clause that it is invalidated
    > > by anybody posting a higher offer to the thread in which it is made.

    >
    > > I am willing to write a roman numeral converter for the OP for US$2000,
    > > payment in advance by certified check or money order. This offer is
    > > valid until midnight (UTC) this Friday, 2007-01-26, or until a higher
    > > offer is made, whichever comes sooner.

    > Isn't it also traditional to offer a discount if the solution can be
    > submitted directly to the instructor?
    >
    > --
    > Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    > San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    > We must do something. This is something. Therefore, we must do this.- Hide quoted text -- Show quoted text -


    I bid my college tuition for next year - see
    http://www.virginia.edu/Facts/Glance_Tuition.htm - plus expenses (I
    figure your pry going to want it to run on Alpha systems, so I going to
    want one of those to develop on - see
    http://h18002.www1.hp.com/alphaserver - hurry, sale ends soon. A SPARC
    system might also be nice.) I'll assign the copyrights of the code to
    you, but I keep the hardware.

    -Ravi Sood http://accordian.sourceforge.net
    rsood, Jan 24, 2007
    #16
  17. ARMAS

    Simon Biber Guest

    ARMAS wrote:
    > Make a program that allows the user to input a number and aoutput it's
    > roman numeral equivalent..... plzzzzzz help....
    > Ex: 109 output:CIX


    I wrote a program to do this. I won't give you all of it but I will give
    you a framework where you can fill in the algorithm.

    #include <stdio.h>
    #include <string.h>

    /*
    Known Roman numerals are:
    I=1, V=5, X=10, L=50, C=100, D=500, M=1000
    Anything greater is represented by appending '~'s.
    Each '~' represents multiplication by 1000.

    The length of the input is unlimited.
    */

    static const char *rom[] = {
    "", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX",
    "", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC",
    "", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"
    };

    int main(int argc, char **argv)
    {
    size_t i, j, k, len, m, numdig;
    const char *p;

    if(argc != 2)
    {
    fprintf(stderr, "Usage requires one argument: "
    "a decimal number to convert.\n");
    return 0;
    }
    numdig = strlen(argv[1]);
    for(i = 0; i < numdig; i++)
    {
    j = numdig - i - 1; /* reverse index */

    if(argv[1] < '0' || argv[1] > '9')
    {
    putchar('\n');
    fprintf(stderr, "Invalid digit: %c\n", argv[1]);
    return 0;
    }

    /* Add your algorithm here. How to determine
    which element of the 'rom' array to
    output?

    It's all about mathematics. Think about the
    values of:

    argv[1] - '0'

    j % 3

    j % 3 * 10

    j / 3
    */

    }
    putchar('\n');
    return 0;
    }

    --
    Simon.
    Simon Biber, Jan 24, 2007
    #17
  18. If this isn't homework, I would love to know how you ended up with such
    a project.


    On Jan 23, 7:18 pm, "ARMAS" <> wrote:
    > On Jan 24, 10:15 am, "user923005" <> wrote:
    >
    > > > >>I'm asking for help, not a bullshit answerThat is where you are wrong (in both regards).

    > > You are not asking for help. You are asking for someone to do your
    > > homework for you. That is decidedly not helpful for your future but
    > > harmful.
    > > Because of your attitude, I am sure that any code answer you receive
    > > will be rather humorous.It ain't a homework....
    Andrew Gentile, Jan 24, 2007
    #18
  19. ARMAS

    Rethish Guest

    Hi;

    I would like to learn how the below mentioned program works.

    how does ??< evaluate to a '(' and how ??( to '['

    could u ppl give a short explanation and if possible point me to some
    info I can read to get more info on this.

    Thanks & regards
    Rethish


    On Jan 24, 7:47 am, "user923005" <> wrote:
    > /*
    > Since we know it's not for school but he just needs this to do his
    > important work,
    > I decided to write a nice converter for him. Enjoy:
    > */
    > #include<stdio.h>
    > #include<stdlib.h>
    > int main(int q0,char*q1??(??))??<long q2,q3;int q4=1;typedef struct q5
    > ??<int q6;char*q7;int q8;char*q9;??>q10;q10 q11??(??)=??<
    > #ifdef q12
    > ??<1000000,"\74\115\55\142\141\162\76",900000,
    > "\74\103\115\55\142\141\162\76"??>,??<500000,
    > "\74\104\55\142\141\162\76",400000,"\74\103\104\55\142\141\162\
    > \76"??>,??<100000,"\74\103\55\142\141\162\76",90000,
    > "\74\130\103\55\142\141\162\76"??>,??<50000,
    > "\74\114\55\142\141\162\76",40000,"\74\130\114\55\142\141\162\
    > \76"??>,??<10000,"\74\130\55\142\141\162\76",9000,
    > "\74\111\130\55\142\141\162\76"??>,??<5000,"\74\126\55\142\141\162\76"
    > ,4000,"\74\111\126\55\142\141\162\76"??>,
    > #endif
    > ??<1000,"\115",900,"\103\115"??>,??<500,"\104",400,"\103\104"??>,??<
    > 100,"\103",90,"\130\103"??>,??<50,"\114",40,"\130\114"??>,??<10,"\130"
    > ,9,"\111\130"??>,??<5,"\126",4,"\111\126"??>,??<1,"\111",1,"\111"??>
    > ??>;int q13=0;if(q0==2)q2=atol(q1??(1??));else??<if(q0==3)??<q2=atol(
    > q1??(1??));q4=0;??>else??<printf("\n\105\156\164\145\162\40\141\156\40"
    > "\151\156\164\145\147\145\162\40\166\141\154\165\145\72\40"
    > );scanf("\45\154\144",&q2);??>??>q3=q2;printf("\n\45\154\144\40\75\40"
    > ,q3);do??<while(q2>=q11??(q13??).q6)??<printf("\45\163",q11??(q13??).
    > q7);q2-=q11??(q13??).q6;??>if(q4)if(q2>=q11??(q13??).q8)??<printf(
    > "\45\163",q11??(q13??).q9);q2-=q11??(q13??).q8;??>q13++;??>while(q2>0)
    > ;return(0);??>
    Rethish, Jan 24, 2007
    #19
  20. ARMAS

    Chris Dollin Guest

    Rethish wrote:

    > I would like to learn how the below mentioned program works.
    >
    > how does ??< evaluate to a '(' and how ??( to '['


    It's (an obscure) part of the definition of C; they're called
    "trigraphs". They don't 'evaluate', they represent.

    > could u ppl give a short explanation and if possible point me to some
    > info I can read to get more info on this.


    Please don't abbreviate "you" and "people" like that. It makes
    your text harder to read for old-timers like what I am. There'
    no hortage of vowel on Uenet.

    --
    Chris "not Wise at all" Dollin
    "Life is full of mysteries. Consider this one of them." Sinclair, /Babylon 5/
    Chris Dollin, Jan 24, 2007
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christopher Benson-Manica

    Roman numerals to ints

    Christopher Benson-Manica, Sep 12, 2003, in forum: C Programming
    Replies:
    13
    Views:
    717
    MikeyD
    Sep 17, 2003
  2. Roman Numerals

    , Aug 17, 2007, in forum: Java
    Replies:
    10
    Views:
    938
    Roedy Green
    Aug 18, 2007
  3. Replies:
    26
    Views:
    1,609
    CBFalconer
    Jan 28, 2008
  4. Ruby Quiz

    [QUIZ] Roman Numerals (#22)

    Ruby Quiz, Mar 4, 2005, in forum: Ruby
    Replies:
    25
    Views:
    355
    James Edward Gray II
    Mar 9, 2005
  5. Ruby Quiz

    [SUMMARY] Roman Numerals (#22)

    Ruby Quiz, Mar 10, 2005, in forum: Ruby
    Replies:
    0
    Views:
    163
    Ruby Quiz
    Mar 10, 2005
Loading...

Share This Page