473,544 Members | 1,776 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3312
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, "NightCrawl er" <mu*********@gm ail.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_thousand s[] =
{"", "M"};

/* not really necessary */
void empty_keyb_buff er(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_buff er();
num_is_ok=(n>=0 )&&(n<=1999);
}

thousands=n/1000;
hundreds=(n%100 0)/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*********@gm ail.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, "NightCrawl er" <mu*********@gm ail.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*********@gm ail.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
4589
by: Ivo | last post by:
Hi, An array contains elements of the form , for example IVa, XIXb, LIX and LXIVc. Does anyone have a function which can sort this array in a way a human would expect it to, with the roman letters treated as their numerical values? I don't think this is a especially problematic thing to do, but I don't want to re-invent the wheel. Thanks Ivo
9
20794
by: level9 | last post by:
How can I convert roman numerals to intergers in c++ VS 6?
13
4357
by: Christopher Benson-Manica | last post by:
Inspired by a thread on clc++, I decided to try it out... #include <stdio.h> #include <stdlib.h> int main( int argc, char *argv ) { int i; int result=0; int this;
10
2462
by: esha | last post by:
I tried several online converters. In many case they do the job, but sometimes give some mess. I think that all converters I know are old, were created for VS 2003 and do not understand new stuff from VS 2005. For instance this block containing Using was not converted by anyone: Public Shared Function GetSiteSettings() As SiteSettings Using...
31
9796
by: ARMAS | last post by:
Make a program that allows the user to input a number and aoutput it's roman numeral equivalent..... plzzzzzz help.... Ex: 109 output:CIX
2
1947
by: bluedemon | last post by:
I've written the program and it works fine. but my instructor said that i can make the program short and use functions in it, but i cant really understand functions that good. so i just need a little help making the program short and use functions too. I'm posting my code here but i'm not posting the cin statements and the validating user entry...
7
6510
by: billbaitsg | last post by:
Hi, I need some help with figuring out why my program is all messed up. There are two portions two it, one that converts from roman to decimal (rom2dec) and another that converts from decimal to roman (dec2rom). int rom2dec(char rom) { //Local Variables int a = 0; //counter int dec = 0;//decimal equivalent
3
6539
by: mookbooker | last post by:
I have a code written out with zero errors but i know my main() function is completely wrong and after i build the solution i compile it and nothing happens!! Not even cout statements please help. // 2.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> #include <iomanip> #include...
3
19289
by: capoeira26 | last post by:
I have is that my entered Roman numerals work only if the numerlas are entered in large to smaller format. For exapmple if I type MMC program will correctly display 2100, but when I enter MCM it will display 2100 instead of 1900. I know that I need to come up with a way to determine what letter comes before so program can subtract it but at this...
0
7359
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7757
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7360
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5895
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5288
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4905
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3398
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
982
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
651
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.