| | |
numeric to figures
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
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.
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.
•
•
Join Date: Aug 2008
Posts: 13
Reputation:
Solved Threads: 1
•
•
•
•
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
C Syntax (Toggle Plain Text)
#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(); }
![]() |
Similar Threads
- Integrating a matlab figure in a Visual c# application (C#)
- Test your talent (Geeks' Lounge)
- Almost There, Going Nowhere (C++)
Other Threads in the C Forum
- Previous Thread: Custom pascal triangle ?
- Next Thread: Rereading files in C
Views: 357 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for C
#include adobe ansi api array arrays asterisks binarysearch calculate centimeter char command convert copyimagefile cprogramme creafecopyofanytypeoffileinc csyntax directory dynamic fflush file fork forloop framework frequency functions getlasterror givemetehcodez grade graphics gtkgcurlcompiling hacking hardware highest homework inches incrementoperators kernel km lazy linked linkedlist linux linuxsegmentationfault list lists locate logical_drives looping loopinsideloop. match matrix microsoft motherboard multi mysql number opendocumentformat opensource owf pattern pdf performance pointer posix problem probleminc process program programming radix recursion recv repetition research scanf scheduling scripting segmentationfault sequential shape socket socketprograming spoonfeeding stack standard string strings structures student systemcall threads turboc unix user variable voidmain() wab win32 windows.h






