Login or Signup

c++ number conversion

Miscellaneous Forums/General Help/c++ number conversion

David819(Posted 1+ years ago) #1

I'm currently learning c++ and trying to make a program as simple as possible to convert int numbers into words e.g. 568 = five hundred and sixty eight, but only problem is i'm not to sure of how to go about getting
1: it to be as short as possible
2: how to get it word values above 19, 100 ect

can anyone help with advice and possible code samples?

Thank you.

TaskMaster(Posted 1+ years ago) #2
There is a post in the code archives that does this, I believe...

AJ00200(Posted 1+ years ago) #3
Store the Strings in an array.
Use a for loop incremented by 100, the a seperate one by 10, and then by one.
NOT C++:
for i=0 to 100
if number > i print strings-hundreds(i)
... repeat with 10s

TaskMaster(Posted 1+ years ago) #4
Here is the code archive function to do it in Blitzmax...

You should be able to take the logic and do it in c++.


David819(Posted 1+ years ago) #5
thanks :) should be able to work it out from the code and advice.