write a program when user enter the number then output will be the in words.for ex.input 123 end output:-one two three.

solution:-
#include<iostream.h>
#include<conio.h>
#include<string.h>
void main()
{
int num,rev=0,rem;
char ch[10]="";  clrscr();
cout<<"enter the numebr"<<endl;
cin>>num;
while(num>0)
{
rem=num%10;
rev=rev*10+rem;
num=num/10;
}
while(rev>0)
{
rem=rev%10;
rev=rev/10;
switch(rem)
{
case 0:
strcpy(ch,"zero");
break;

case 1:
strcpy(ch,"one");
break;

case 2:
strcpy(ch,"two");
break;

case 3:
strcpy(ch,"three");
break;

case 4:
strcpy(ch,"four");
break;

case 5:
strcpy(ch,"five");
break;

case 6:
strcpy(ch,"six");
break;

case 7:
strcpy(ch,"seven");
break;

case 8:
strcpy(ch,"eight");
break;

case 9:
strcpy(ch,"nine");
break;
default:
ch=="";
break;
}
cout<<ch;
}
getch();
}

No comments:

Post a Comment

Blogger Tips and TricksLatest 

Tips For BloggersBlogger Tricks