At 10/22/2009 06:28 AM, you wrote: >hi i m a new learner of c++ im making a program in which user will enter the >numbers(digits) and will get the same number in words by the computer in it >i made an array and stored the number user can enter any number say 23 or >325436 for that i had made a for loop which will work as user will enter how >many no.s he want to enter but the basic problem is that i m not able to >convert them into words i can use ascii values but i m not getting the >logic how to implement this as i recently started working in c++ i dont know >what to do in this case can any body help me in this case
Like this (below)? You need to parse through the number. I created a "word" array and processed the number from right (least-significant) to left. Then I printed the array in reverse order. You will also want to determine the relative position of each digit (ones, tens, hundreds, thousands, etc.) in order to print the proper values. You will (probably) want to make note of special cases (e.g. eleven instead of one one, twenty-seven instead of two seven, n thousand) and output words accordingly. ~Rick C:\> numbertowords Please enter a number (0 to quit): 2345233 Your number was 2345233.0 TWO MILLION THREE HUNDRED FORTY-FIVE THOUSAND TWO HUNDRED THIRTY-THREE POINT ZERO Please enter a number (0 to quit): 7654.3452 Your number was 7654.3452 SEVEN THOUSAND SIX HUNDRED FIFTY-FOUR POINT THREE FOUR FIVE TWO Please enter a number (0 to quit): 1324576809.1524367098 Your number was 1324576809.1524367098 ONE BILLION THREE HUNDRED TWENTY-FOUR MILLION FIVE HUNDRED SEVENTY-SIX THOUSAND EIGHT HUNDRED NINE POINT ONE FIVE TWO FOUR THREE SIX SEVEN ZERO NINE EIGHT Please enter a number (0 to quit): 0 C:\>
