Add to Favorites    Make Home Page 4328 Online  
 Language Categories  
 Our Services  

Home » C Home » Beginners / Lab Assignments Home » Digit to words

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title Digit to words
Author Priyank Luthra
Author Email priyank.luthra [at] gmail.com
Description This program converts any number written in digits to equivalent word representation. eg. if i/p is 232, output is "two hundered thirty two".
Category C » Beginners / Lab Assignments
Hits 368361
Code Select and Copy the Code
Code : //Program to convert digit representation to equivalent word representation //By Priyank Luthra BE computer Engg. DCE #include<stdio.h> #include<conio.h> struct std{ int dig; char wrd[20]; }; struct std fig[]={{1,"one"},{2,"two"},{3,"three"},{4,"four"},{5,"five"},{6,"six"}, {7,"seven"},{8,"eight"},{9,"nine"},{10,"ten"},{11,"eleven"},{12,"twelve"}, {13,"thirteen"}, {14,"fourteen"},{15,"fifteen"},{16,"sixteen"},{17,"seventeen"},{18,"eighte en"},{19,"nineteen"}, {20,"twenty"},{30,"thirty"},{40,"fourty"},{50,"fifty"},{60,"sixty"},{70,"s eventy"},{80,"eighty"}, {90,"ninety"}}; int num1[5],i; op0(long num) { for(i=0;i<20;i++) if(fig[i].dig==num) printf("%s",fig[i].wrd); } op1(long num) { //num1=num; num1[0]=num/10; num1[0]=num1[0]*10; num1[1]=num%10; for(i=0;i<27;i++) {if(fig[i].dig==num1[0]) printf("%s ",fig[i].wrd); } for(i=0;i<20;i++) {if(fig[i].dig==num1[1]) printf("%s",fig[i].wrd); } } op2(long num) { int k,j=num%100; k=num/100; for(i=0;i<10;i++) {if(fig[i].dig==k) {printf("%s hundred ",fig[i].wrd); if(j>0&&j<20) op0(num%100); else op1(num%100); } } } op3(long num) { int k,j=num%1000; k=num/1000; for(i=0;i<10;i++) { if(fig[i].dig==k) { printf("%s thousand ",fig[i].wrd); if(j>=1&&j<10) op0(num%1000); else if(j>10&&j<100) op1(num%1000); else op2(num%1000); } } } op4(long num) { int k=num/1000,j; j=num%1000; if(k<=20) { op0(num/1000); printf(" thousand "); if(j>0&&j<10) op0(num%1000); if(j>10&&j<100) op1(num%1000); else op2(num%1000); } if((k>20)&&(k<100)) { op1(num/1000); printf(" thousand "); if(j>0&&j<10) op0(num%1000); if(j>10&&j<100) op1(num%1000); else op2(num%1000); } //op2(num%1000); } op5(long num) { int k=num/100000; int j=num%100000; for(i=0;i<10;i++) { if(fig[i].dig==k) { printf("%s lakh ",fig[i].wrd); if(j>0&&j<20) op0(num%100000); if(j>20&&j<100) op1(num%100000); if(j>100&&j<1000) op2(num%100000); if(j>1000&&j<10000) op3(num%100000); if(j>10000&&j<100000) op4(num%100000); } } } main() { long num; clrscr(); printf("Enter the number "); scanf("%ld",&num); if(num<=20) op0(num); if((num>20)&&(num/100==0)) op1(num); if(num==100) printf("hundred"); if(num>100&&num<1000) op2(num); if(num==1000) printf("one thousand"); if(num>1000&&num<10000) op3(num); if(num==10000) printf("ten thousand"); if(num>10000&&num<100000) op4(num); if(num==100000) printf("one lakh"); if(num>100000&&num<1000000) op5(num); if(num==1000000) printf("One crore"); getch(); }

Related Source Codes

Script Name Author
The Game Opposite as seen on Nokia 2300 Mobile Manikanta
RECURSIVE BALANCED QUICK SORT ashish
Radix Sort ashish
Change your mouse pointer Ashim
The blinking star Shashank
Data Validation Crylittlebaby
To search a file by giving file type like mp3 or mpeg or doc Prashanth SR
Menus Demonstration B.Chidhambaram
Employee Database Project Using C. Reenku Raman Nayak
Creating a Lexical Analyzer in c fahad bader al-buhairi ¦Õ¤ ?¤Ð Ãß??ÝÐÝ
Calendar Program Omkar & Devendra
Stop double Process for start in C Cedrik Jurak
Stop double Process for start in C Cedrik Jurak
Time Scheduler Atiq Anwar
A timepass game between atmost two players Rahul Roy

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=1043


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review