Convert any number to word Posted: 29 Jun 2014 09:39 PM PDT Q. Write a C program to convert any number to words, for example if user entered number = 45764then output = Four Five Seven Six Four Ans. /*c program for convert number to word*/#include<stdio.h>int main(){ int num,c,digit,r=0; char *ch[1000]; printf("Enter Number/Digit : "); scanf("%d", &num); while(num) { digit=num%10; num=num/10; switch(digit) { case 0: ch[r++]="Zero"; break; case 1: ch[r++]="One"; break; case 2: ch[r++]="Two"; break; case 3: ch[r++]="Three"; break; case 4: ch[r++]="Four"; break; case 5: ch[r++]="Five"; break; case 6: ch[r++]="Six"; break; case 7: ch[r++]="Seven"; break; case 8: ch[r++]="Eight"; break; case 9: ch[r++]="Nine"; break; } } printf("Your Entered Number In Word : "); for(c=r; c>=0; c--) printf("%s", ch[c]); getch(); return 0;}
/************************************************************ The output of above program would be: **************************************************************/
| Figure: Screen shot for Convert number to word C program |
Related program:- Convert any number to grammatical words C program
- Comparison of million/billion/trillion VS lakh/crore/kharab
|
Post a Comment