numeric to figures

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2006
Posts: 42
Reputation: bluebird is an unknown quantity at this point 
Solved Threads: 0
bluebird bluebird is offline Offline
Light Poster

numeric to figures

 
0
  #1
Mar 10th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,572
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1485
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: numeric to figures

 
0
  #2
Mar 10th, 2009
moved. You didn't say what programming language so I assumed C. Next time don't post tech questions in Geek's Lounge.
Last edited by Ancient Dragon; Mar 10th, 2009 at 3:57 pm.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 42
Reputation: bluebird is an unknown quantity at this point 
Solved Threads: 0
bluebird bluebird is offline Offline
Light Poster

Re: numeric to figures

 
0
  #3
Mar 10th, 2009
Yes.
I intended to post in c. I don't know how it was get to the Geek's Lounge.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,572
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1485
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: numeric to figures

 
0
  #4
Mar 10th, 2009
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.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 96
Reputation: Dewey1040 is an unknown quantity at this point 
Solved Threads: 3
Dewey1040 Dewey1040 is offline Offline
Junior Poster in Training

Re: numeric to figures

 
0
  #5
Mar 10th, 2009
divide by 10 to erase the right most digit use % 10 to single out the right most digit
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 13
Reputation: rajenpandit is an unknown quantity at this point 
Solved Threads: 1
rajenpandit rajenpandit is offline Offline
Newbie Poster

Re: numeric to figures

 
0
  #6
Mar 14th, 2009
Originally Posted by bluebird View Post
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..............
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<string.h>
  4. void main()
  5. {
  6. int num,numcnt,div,i=1,n=0;
  7. char str[10][10];
  8. clrscr();
  9. printf("Enter a num :");
  10. scanf("%d",&num);
  11. numcnt=num;
  12. while(numcnt>0)
  13. {
  14. numcnt=numcnt/10;
  15. i=i*10;
  16. }
  17. while(num>0)
  18. {
  19. i=i/10;
  20. div=num/i;
  21. num=num%i;
  22. if(div==0)
  23. strcpy(str[n],"Zero");
  24. else if(div==1)
  25. strcpy(str[n],"One");
  26. else if(div==2)
  27. strcpy(str[n],"Two");
  28. else if(div==3)
  29. strcpy(str[n],"Three");
  30. else if(div==4)
  31. strcpy(str[n],"Four");
  32. else if(div==5)
  33. strcpy(str[n],"Five");
  34. else if(div==6)
  35. strcpy(str[n],"Six");
  36. else if(div==7)
  37. strcpy(str[n],"Seven");
  38. else if(div==8)
  39. strcpy(str[n],"Eight");
  40. else if(div==9)
  41. strcpy(str[n],"Nine");
  42. n++;
  43. }
  44. for(i=0;i<n;i++)
  45. printf("%s ",str[i]);
  46. getch();
  47. }
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC