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
Hope you liked my posts, give comments if you have any doubts.. :)
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:#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();
}
C Program to Convert Digits to its Equivalent Words
Hope you liked my posts, give comments if you have any doubts.. :)
No comments:
Post a Comment