# Thread: program to convert numbers into words

1. ## program to convert numbers into words

hi all,

I was trying to write a program that converts numeric figures into words i.e. 342 gets printed as three hundred forty two.

I have reached the stage where i can convert any number like 342 into three four two but not three hundred forty two with the following code, any suggestions?

Code:
```main()
{
unsigned int num,num2,no_dig=0,p;
int i;

printf("\nEnter any positive integer : ");
scanf("%d",&num);

do
{
no_dig++;
num2=num2/10;
} while(num2!=0);

for(;no_dig>0;no_dig--,num%=p)
{
p=1;
for(i=no_dig-1;i>0;i--)
p=p*10;

switch(num/p)
{

case 0:
printf("ZERO");
break;

case 1:
printf("ONE");
break;

case 2:
printf("TWO");
break;

case 3:
printf("THREE");
break;

case 4:
printf("FOUR");
break;

case 5:
printf("FIVE");
break;

case 6:
printf("SIX");
break;

case 7:
printf("SEVEN");
break;

case 8:
printf("EIGHT");
break;

case 9:
printf("NINE");
break;

}
}
}```

2. Make a lookup table for every number there is...

Quzah.

3. >Make a lookup table for every number there is...

ROFLCOPTER!

4. Code:
```int n = 342;
char *c = (char*)n;
printf("%s", c);```

Ok, so that doesn't work.

Think. Given a number like 342, how would YOU convert it into an ordinal? Invent a step-by-step way to do it, and translate it into code.

5. I wonder if the search feature still works.

6. yes I found the code, thanks a lot