12,511,263 members (38,330 online)
Rate this:
See more:
Hello,

I need a c++ program that take an integer input value from 1 to 999 and display its word. For example if the user enter 358 then output should be "Three hundred and fifty eight".

Posted 4-May-10 6:06am
Updated 4-May-10 6:11am
v2

Rate this:

## Solution 1

Google[^] not working where you are?
Rate this:

## Solution 3

Should look something like this:

```int main()
{
cout<<"Enter an integer between 1 and 999\n";
int a;
cin>>a;

if (a==1)
{
cout<<"One\n";
}
else if (a==2)
{
cout<<"Two\n";
}
else if (a==3)
{
cout<<"Three\n";
}
// else if... repeat till 999
}
```
OriginalGriff 4-May-10 15:03pm

It has the advantages of working, being very tedious to enter, and failing his course! I like it :laugh:
William Winner 4-May-10 15:04pm

nice...shouldn't take too long to implement!
emilio_grv 7-May-10 7:47am

OK... it works.
Now let's chage it top work up to 1'000'000
:-)
Rate this:

## Solution 2

What do you think to learn if someone else does your homework for you?
CPallini 4-May-10 13:08pm

'How to obtain a career in Management', I suppose.
:-)
Sauro Viti 4-May-10 13:17pm

:-) Hey! You are right! There is someone who like to do my homeworks?
Rate this:

## Solution 4

```int main()
{
cout<<"Enter an integer between 1 and 999\n";
int a;
cin>>a;
int result[3];
int i;
for(i=0;i<3&&a>0;i++)
{
result[i]=a%10;
a=a/10;
}
if(a<0)
i-=1;

for(int j=i; j>=0;j--)
{
switch(result[j])
{
case 0:
cout<<"zero";
break;
case 1:
cout<<"one";
break;
case 2:
cout<<"two";
break;
.... till "9"
}
}
}```
v3
CPallini 27-May-13 6:18am

What's the purpose of adding a wrong solution to a three years old question?
satz_770 28-May-13 1:08am

Updated it , now check, instead of a simple thing you are writing it from 0 to 999, that made me give this solution!!!

Top Experts
Last 24hrsThis month
 OriginalGriff 255 David_Wimbley 200 Midi_Mick 140 Suvendu Shekhar Giri 105 CPallini 100
 OriginalGriff 8,134 Maciej Los 4,119 ppolymorphe 4,086 David_Wimbley 3,486 Karthik Bangalore 3,196