hello
Is there any way to change numeric to figures?
for example if the user input is 134, the program output must be one three four.


thanks in advance,
Bluebird

Yes.
I intended to post in c. I don't know how it was get to the Geek's Lounge.

One way to do it is to make an array of strings that contain the words for each number, then index into that array with each digit of the integer. To get each digit of the integer you will need a loop, use the % operator, and the / (divide) operator.

hello
Is there any way to change numeric to figures?
for example if the user input is 134, the program output must be one three four.


thanks in advance,
Bluebird

Check it out..............

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
	int num,numcnt,div,i=1,n=0;
	char str[10][10];
	clrscr();
	printf("Enter a num :");
	scanf("%d",&num);
	numcnt=num;
	while(numcnt>0)
	{
		numcnt=numcnt/10;
		i=i*10;
	}
	while(num>0)
	{
		i=i/10;
		div=num/i;
		num=num%i;
		if(div==0)
			strcpy(str[n],"Zero");
		else if(div==1)
			strcpy(str[n],"One");
		else if(div==2)
			strcpy(str[n],"Two");
		else if(div==3)
			strcpy(str[n],"Three");
		else if(div==4)
			strcpy(str[n],"Four");
		else if(div==5)
			strcpy(str[n],"Five");
		else if(div==6)
			strcpy(str[n],"Six");
		else if(div==7)
			strcpy(str[n],"Seven");
		else if(div==8)
			strcpy(str[n],"Eight");
		else if(div==9)
			strcpy(str[n],"Nine");
		n++;
	}
	for(i=0;i<n;i++)
		printf("%s ",str[i]);
	getch();
}
This article has been dead for over six months. Start a new discussion instead.