My site has been moved!

You should be automatically redirected in 6 seconds. If not, visit
http://www.hackagenius.co.cc
and update your bookmarks.




C Program to Print the Entered Number in Words

Posted by smit sanghvi Monday, November 2, 2009

The following C program print’s the entered number in words.For example if the number entered is 12345 then the program prints the entered number in words as One Two Three Four Five


#include
void main()
{
int i=0;
unsigned long int digit;
char str[12],ch;
puts(”Enter the number (less than 10 digit)”);
scanf(”%lu”,&digit);
ultoa(digit,str,10); /*converts an unsigned long int to string*/
while(str[i]!=’\0′)
{
ch=str[i];
i++;
switch(ch)
{
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;
}
}
}

0 comments

Post a Comment

Visit our new website

Our Newsletter

Enter your email address To Subscribe Us Via Email:

Our SMS Updates