Hello, i need help to convert any 1, 2, or 3 digit number into words using string/array method in C++. For example, 111 should read one hundred and eleven, 011 should read eleven, 001 should read one. I would much appreciate it if you could help me solve this problem. I have done a little of it so far and it is correct up to this point and no modifications should be necessary. It should also be short (30 lines max.)

``````#include<iostream>
using namespace std;
int main()
{
int A,B,C,number;
string a[]={"zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"};
string b[]={"twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"};
string c[]={"hundred"};
cout<<"Please enter a three digit number";``````

> I have done a little of it so far and it is correct up to this point
This is true. It is very hard to get array declarations and a prompt for input wrong. :D Ed is inclined to believe that you accidentally pasted only a portion of your code rather than all of it.

It looks like this is a homework assignment.

Looks like you're on the right track, just keep in mind that if you have to account for all 999 cases of 3 digit numbers then it would be advantageous for you to look for word aliasing. For instance, eleven occurs 11 times within that range. hundred occurs 900 times etc. Looks like you're headed that way.

guyz can convert this... this the problem.. conversion of numbers into words maximum 999,999... sample output:
enter: 192,453
figure: one hundred ninety two thousand four fifty three

help me guyz....

No one is here to give you a copy paste code, you have to do work for that.
You work quite fine until now..........

Further what you have do thats I will explain bellow

Take user input in a integer type variable for example num
Use a string variable to store converted input in word and initialize it with NULL
Then you have to check your last two digit number is less then 20 or not

IF LASTTWODIGIT <20 THEN
INWORD=a[LASTTWODIGIT]+" "+INWORD
OTHERWISE
INWORD=b[DIGIT_AT_TENTH_PLACE]+" "+a[DIGIT_AT_ONES_PLACE]+" "+INWORD

INWORD=a[DIGIT_AT_HUNDREDS_PLACE]+" "+INWORD

FOR EXAMPLE: num=456

LASTTWODIGIT=56
DIGIT_AT_HUNDRED_PLACE=4
DIGIT_AT_TENS_PLACE=5
DIGIT_AT_ONCES_PLACE=6

Best Of Luck