C Program to Print the Entered Number in Words
Submitted by Srikanth on Tuesday, 4 December 20077 Comments
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<stdio.h>
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;
}
}
}
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;
}
}
}
Related Posts
By using/following this site you agree to our Legal Disclaimer

Hi Srikanth,
How to print figures in Words? Like 1500 will be printed as “Fifteen hundred”, 10205 will be printed as “Ten thousand two hundred five”.
Please mail me the code in “C” ASAP.
Thanks,
Sony
How to use this code ? What extensino do we have to put ?
@ me
Save the program in a notepad and change the extension from .txt to .c
i want program which print no given by user in words
example:= 1999:=one thousand nine hundred ninty nine.
Hello, I’ve written a version that prints number in words like ‘one thousand nine hundred ninty nine’. Here’s it -
Sorry, this is the link - http://jithusunnyk.blogspot.com/2011/11/wordifyc-prints-number-in-words.html
How u can write so difficult..difficult programs?
Leave your response!
I am the author and founder of GoHacking. You can read more about me or get in touch with me on Google+ or contact page.
EMAIL SECURITY »
What to Do When Your Email Account is Hacked?
How to Recover Hacked Email Accounts?
It can be a real nightmare if someone hacks and takes control of your email account as it may contain confidential information like bank logins, credit card details and other sensitive data. …
HOW STUFFS WORK »
How Antivirus Software Works
Due to ever increasing threat from virus and other malicious programs, almost every computer today comes with a pre-installed antivirus software on it. In fact, an antivirus has become one of the most essential software package for every computer. Even though every one …
HOW-TO GUIDES »
How to Retrieve Clipboard History in Windows
Ever copied a code snippet or text from the web and forgot to paste it before you copied something else? Well, all of us will have an experience of something like this, where we want to …
INTERNET SECURITY »
How to Hide Data in Image, Audio & Video Files: Steganography
Ever wondered to know how to hide secret messages in images, audio and video files? Well, in this post I will take you through a concept called steganography using which, it is possible to hide your secret information …
NETWORK HACKS »
Customize Google to Improve Search Results
Google is indisputedbly the best search engine out there on the Internet, however there are a few ways by which you can customize Google and make it even better. I have got 3 best free Firefox extensions using which you …
Categories
Most Popular
Most Commented
Blogroll
Log In | Entries (RSS) | Comments (RSS) | Sitemap
© 2008-2012 GoHacking.Com. This content is copyrighted to Srikanth and may not be reproduced on other websites.