So do you want to do this in C (which is the code you posted) or C++?

Printable View

- 07-05-2011AndrewHunter
So do you want to do this in C (which is the code you posted) or C++?

- 07-05-2011Carr Paulo
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..

- 07-05-2011whiteflagsQuote:

Ordinary Numbers = Roman Numerals

1=I

5=V

10=X

50=L

100=C

500=D

100=M

- 07-05-2011MatticusQuote:

Ordinary Numbers = Roman Numerals

1=I

5=V

10=X

50=L

100=C

500=D

**1000=M**

- 07-05-2011AndrewHunter
- 07-05-2011Carr Paulo
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/

- 07-05-2011MatticusQuote:

my problem is this...please help. i need a algorithm and solution,,

If not, then the very first numeral is not 'M'. If so, then the very first numeral is 'M'. - 07-05-2011Carr Paulo
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 }.. - 07-05-2011Carr Paulo
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. - 07-05-2011Matticus
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!** - 07-05-2011whiteflags
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. - 07-05-2011Carr Paulo
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?? - 07-05-2011King Mir
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. - 07-05-2011Matticus
WhiteFlags gave you really good advice, much better than mine. You should read that thoroughly, it should answer your question.

- 07-05-2011Carr Paulo
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..