February 5, 2011

C++ Program to Convert Digits to its Equivalent Words


Here is another tricky code, where we can Convert Digits to its Equivalent Words.

The program work till 5 digits of number

Suppose the Input is: 12345

Then the Output will be:  OneTwoThreeFourFive


Code:

//C++ Program to Convert Digits to its Equivalent Words
#include<iostream.h>
#include<conio.h>
void main()
{
int a[5],i,n;
clrscr();
cout<<"Enter the Value";
cin>>n;
for(i=4;i>=0;i--)
{
a[i]=n%10;
n=n/10;
}
for(i=0;i<5;i++)
{
if(a[i]!=0)
{
switch(a[i])
{
case 0:cout<<"Zero";
break;
case 1:cout<<"One";
break;
case 2:cout<<"Two";
break;
case 3:cout<<"Three";
break;
case 4:cout<<"Four";
break;
case 5:cout<<"Five";
break;
case 6:cout<<"Six";
break;
case 7:cout<<"Seven";
break;
case 8:cout<<"Eight";
break;
case 9:cout<<"Nine";
break;
}
}
}
getch();
}

Also Read:


C Program to Convert Digits to its Equivalent Words


Hope you liked my posts, give comments if you have any doubts.. :)

Related Posts :



Categories: , ,

1 comments:

Nice site .....
it works...

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Related Posts with Thumbnails