//For ex: if enetered number is '1234' the output will be "One Two Three Four"
#include<stdio.h>
#include<stdlib.h>
void main()
{
int digit, num, rev=0, n, m, i, count=0;
printf("\nEnter an integer: ");
scanf("%d", &num);
m=num;
while(num>0)
{
digit=num%10;
count++;
num=num/10;
rev=rev*10+digit;
}
n=rev;
rev=0;
if(m%10!=0)
{
while(n>0)
{
digit=n%10;
switch(digit)
{
case 1 : printf(" One");
break;
case 2 : printf(" Two");
break;
case 3 : printf(" Three");
break;
case 4 : printf(" Four");
break;
case 5 : printf(" Five");
break;
case 6 : printf(" Six");
break;
case 7 : printf(" Seven");
break;
case 8 : printf(" Eight");
break;
case 9 : printf(" Nine");
break;
case 0 : printf(" Zero");
break;
}
n=n/10;
rev=rev*10+digit;
}
}
else
{
for(i=0;i<count;i++)
{
digit=n%10;
switch(digit)
{
case 1 : printf(" One");
break;
case 2 : printf(" Two");
break;
case 3 : printf(" Three");
break;
case 4 : printf(" Four");
break;
case 5 : printf(" Five");
break;
case 6 : printf(" Six");
break;
case 7 : printf(" Seven");
break;
case 8 : printf(" Eight");
break;
case 9 : printf(" Nine");
break;
case 0 : printf(" Zero");
break;
}
n=n/10;
}
}
printf("\n");
printf("\nPress ENTER to EXIT\n");
getch();
}
No comments:
Post a Comment