468,512 Members | 1,337 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

int to roman converter

Hi everybody i need code for converting integer no to roman i.i
1->I,5->V n so on....
plz help me i want to use it in a spin control

Sep 27 '06 #1
9 3185
NightCrawler wrote:
Hi everybody i need code for converting integer no to roman i.i
1->I,5->V n so on....
plz help me i want to use it in a spin control
Pssst! Here is a secret web site where you can find stuff (but
don't tell anybody): www.google.com
Sep 27 '06 #2
On 27 Sep 2006 14:33:42 -0700, "NightCrawler" <mu*********@gmail.com>
wrote:
>Hi everybody i need code for converting integer no to roman i.i
1->I,5->V n so on....
#include <stdio.h>

const char *roman_digits[] =
{"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"};
const char *roman_tens[] =
{"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"};
const char *roman_hundreds[] =
{"", "C", "CC", "CCC", "CD", "D", "DX", "DXX", "DXX", "CM"};
const char *roman_thousands[] =
{"", "M"};

/* not really necessary */
void empty_keyb_buffer(void) { while (getchar()!='\n') ; }

int main()
{
int n, num_is_ok=0, digits, tens, hundreds, thousands;

while (!num_is_ok) {
printf("insert a number between 0 and 1999: ");
scanf("%d", &n);
empty_keyb_buffer();
num_is_ok=(n>=0)&&(n<=1999);
}

thousands=n/1000;
hundreds=(n%1000)/100;
tens=(n%100)/10;
digits=n%10;

printf("Roman equivalent: %s%s%s%s\n",
roman_thousands[thousands],
roman_hundreds[hundreds],
roman_tens[tens],
roman_digits[digits]);

return 0;
}
Sep 27 '06 #3
Andrea Laforgia wrote:
NightCrawler wrote:
>>Hi everybody i need code for converting integer no to roman i.i
1->I,5->V n so on....

#include <stdio.h>
Andrea, please refrain from doing people's homework for them. We don't want
such people to graduate and then join our teams, because we will still be
doing their homework!

--
Phlip
http://www.greencheese.us/ZeekLand <-- NOT a blog!!!
Sep 27 '06 #4
Andrea, please refrain from doing people's homework for them. We don't
want such people to graduate and then join our teams, because we will
still be doing their homework!
My bad - I just read the question. People doing homework probably wouldn't
use a "spin control" as their cover story!

Carry on! (And Andrea should use C++ things like <iostream>, and use
code-robustness things like unit tests...)

--
Phlip
http://www.greencheese.us/ZeekLand <-- NOT a blog!!!
Sep 27 '06 #5
NightCrawler <mu*********@gmail.comwrote:
>Hi everybody i need code for converting integer no to roman i.i
1->I,5->V n so on....
plz help me i want to use it in a spin control
Spin control? Does this have something to do with the Pope's
recent faux pas?

S.
Sep 27 '06 #6
Andrea Laforgia wrote:
On 27 Sep 2006 14:33:42 -0700, "NightCrawler" <mu*********@gmail.com>
wrote:
>Hi everybody i need code for converting integer no to roman i.i
1->I,5->V n so on....

#include <stdio.h>

const char *roman_digits[] =[..]
Are you worried about your job security that you are so eager to
proliferate somebody else's lazyness by doing their homework?
Sep 28 '06 #7
Steve Pope wrote:
NightCrawler <mu*********@gmail.comwrote:
>Hi everybody i need code for converting integer no to roman i.i
1->I,5->V n so on....
plz help me i want to use it in a spin control

Spin control? Does this have something to do with the Pope's
recent faux pas?

S.
No, I think it has to do with the HP fiasco.
Sep 28 '06 #8
thanx, Andrea
was a nice one..
Actually i was seeking for logic only not the code coz i wont be able
to use it as it is.....
n plz stop arguing that was nobodies HOMEWORK......

Sep 28 '06 #9
NightCrawler wrote:
Actually i was seeking for logic only not the code coz i wont be able
to use it as it is.....
You also won't be able to use this as-is, but it's logical:

http://www.xpsd.org/cgi-bin/wiki?TutorialRomanNumerals
n plz stop arguing that was nobodies HOMEWORK......
You might notice I retracted...

--
Phlip
http://www.greencheese.us/ZeekLand <-- NOT a blog!!!
Sep 28 '06 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Ivo | last post: by
9 posts views Thread by level9 | last post: by
13 posts views Thread by Christopher Benson-Manica | last post: by
10 posts views Thread by esha | last post: by
31 posts views Thread by ARMAS | last post: by
7 posts views Thread by billbaitsg | last post: by
3 posts views Thread by mookbooker | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.