473,698 Members | 2,139 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 3320
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
4608
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
20809
by: level9 | last post by:
How can I convert roman numerals to intergers in c++ VS 6?
13
4382
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
2496
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 connection As New...
31
9829
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
1960
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 loops. i'm just posting the if statements that i used. so here is my code: thousands =...
7
6531
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
6552
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 <cstring>
3
19309
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 point am little stuck. Here is my code: package chapt08; import javax.swing.JOptionPane;
0
8598
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8887
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8856
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7709
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5858
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4360
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4613
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2321
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.