| | |
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
| Thread Tools | Search this Thread |
Tag cloud for C
adobe ansi api array arrays bash binarysearch centimeter char convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic fflush file fork frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hardware highest homework i/o ide inches infiniteloop initialization interest kilometer km lazy linked linkedlist linux linuxsegmentationfault list locate logical_drives match matrix meter microsoft motherboard multi mysql open opendocumentformat opensource openwebfoundation owf pattern pdf performance pointer pointers posix power problem probleminc program programming pyramidusingturboccodes read recursion recv repetition scanf scheduling segmentationfault send shape single socketprograming socketprogramming spoonfeeding stack standard strchr string strings structures suggestions system systemcall test testautomation unix user voidmain() wab win32api windows.h






