write a program that accepts a number and outputs its
equivalent in words.
take note that the maximum input is 3000

Answer Posted / sandeep

Buddy it will accept any no. less than 1crore



prog in C


#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<dos.h>
#include<process.h>
int main()
{
int l=0;
char n[6],i ;
clrscr();
printf("enter number");
scanf("%s",n);
l=strlen(n);
if(l==1)
{
switch(n[0])
{
case '0':
printf("zero");
getch();
exit(0);
case '1':
printf("one");
getch();
exit(0);
case '2':
printf("two");
getch();
exit(0);
case '3':
printf("three");
getch();
exit(0);
case '4':
printf("four");
getch();
exit(0);
case '5':
printf("five");
getch();
exit(0);
case '6':
printf("six");
getch();
exit(0);
case '7':
printf("seven");
getch();
exit(0);
case '8':
printf("eight");
getch();
exit(0);
case '9':
printf("nine");
getch();
exit(0);
}}


if(l==2)
{
switch(n[0])
{case '1':
switch(n[1])
{
case '0':
printf("ten");
getch();
exit(0);
case '1':

printf("eleven");
getch();
exit(0);
case '2':
printf("twelve");
getch();
exit(0);
case '3':
printf("thirteen");
getch();
exit(0);
case '4':
printf("fourteen");
getch();
exit(0);
case '5':
printf("fifteen");
getch();
exit(0);
case '6':
printf("sixteen");
getch();
exit(0);
case '7':
printf("seventeen");
getch();
exit(0);
case '8':
printf("eighteen");
getch();
exit(0);
case '9':
printf("ninteen");
getch();
exit(0);
}
case'2': printf("twenty\t");
break;
case'3': printf("thirty\t");
break;
case'4': printf("fourty\t");
break;
case'5': printf("fifty\t");
break;
case'6': printf("sixty\t");
break;
case'7': printf("seventy\t");
break;
case'8': printf("eighty\t");
break;
case '9':printf("ninty\t");
break;
}
switch(n[1])
{
case '1':
printf("one");
getch();
exit(0);
case '2':
printf("two");
getch();
exit(0);
case '3':
printf("three");
getch();
exit(0);
case '4':
printf("four");
getch();
exit(0);
case '5':
printf("five");
getch();
exit(0);
case '6':
printf("six");
getch();
exit(0);
case '7':
printf("seven");
getch();
exit(0);
case '8':
printf("eight");
getch();
exit(0);
case '9':
printf("nine");
getch();
exit(0);
}}


if(l==3){
switch(n[0])
{
case'1':printf("one hundred and");
break;
case'2': printf("two hundred and");
break;
case'3': printf("three hundred and");
break;
case'4': printf("four hundred and");
break;
case'5': printf("five hundred and");
break;
case'6': printf("six hundred and");
break;
case'7': printf("seven hundred and");
break;
case'8': printf("eight hundred and");
break;
case '9':printf("ninte hundred and");
break;
}
switch(n[1])
{
case'0':
break;
case '1':
switch(n[2])
{

case '0':
printf("ten");
getch();
exit(0);
case '1':

printf("eleven");
getch();
exit(0);
case '2':
printf("twelve");
getch();
exit(0);
case '3':
printf("thirteen");
getch();
exit(0);
case '4':
printf("fourteen");
getch();
exit(0);
case '5':
printf("fifteen");
getch();
exit(0);
case '6':
printf("sixteen");
getch();
exit(0);
case '7':
printf("seventeen");
getch();
exit(0);
case '8':
printf("eighteen");
getch();
exit(0);
case '9':
printf("ninteen");
getch();
exit(0); }


case'2': printf(" twenty");
break;
case'3': printf(" thirty");
break;
case'4': printf(" fourty");
break;
case'5': printf(" fifty");
break;
case'6': printf(" sixty");
break;
case'7': printf(" seventy");
break;
case'8': printf(" eighty");
break;
case '9':printf(" ninty");
break;
}


switch(n[2])
{
case '1':
printf("one");
getch();
exit(0);
case '2':
printf("two");
getch();
exit(0);
case '3':
printf("three");
getch();
exit(0);
case '4':
printf("four");
getch();
exit(0);
case '5':
printf("five");
getch();
exit(0);
case '6':
printf("six");
getch();
exit(0);
case '7':
printf("seven");
getch();
exit(0);
case '8':
printf("eight");
getch();
exit(0);
case '9':
printf("nine");
getch();
exit(0);
}
}



if(l==4)
{
switch(n[0])
{
case '1':
printf("one thousand");
break;
case '2':
printf("two thousand");
break;
case '3':
printf("three thousand");
break;
case '4':
printf("four thousand");
break;
case '5':
printf("five thousand");
break;
case '6':
printf("six thousand");
break;
case '7':
printf("seven thousand");
break;
case '8':
printf("eight thousand");
break;
case '9':
printf("nine thousand");
break;
}








switch(n[1])
{case '0';
case'1':printf(" one hundred and");
break;
case'2': printf(" two hundred and");
break;
case'3': printf(" three hundred and");
break;
case'4': printf(" four hundred and");
break;
case'5': printf(" five hundred and");
break;
case'6': printf(" six hundred and");
break;
case'7': printf(" seven hundred and");
break;
case'8': printf(" eight hundred and");
break;
case '9':printf(" ninte hundred and");
break;
}
switch(n[2])
{
case'0':
break;
case '1':
switch(n[3])
{

case '0':
printf("ten");
getch();
exit(0);
case '1':

printf("eleven");
getch();
exit(0);
case '2':
printf("twelve");
getch();
exit(0);
case '3':
printf("thirteen");
getch();
exit(0);
case '4':
printf("fourteen");
getch();
exit(0);
case '5':
printf("fifteen");
getch();
exit(0);
case '6':
printf("sixteen");
getch();
exit(0);
case '7':
printf("seventeen");
getch();
exit(0);
case '8':
printf("eighteen");
getch();
exit(0);
case '9':
printf("ninteen");
getch();
exit(0); }


case'2': printf(" twenty");
break;
case'3': printf(" thirty");
break;
case'4': printf(" fourty");
break;
case'5': printf(" fifty");
break;
case'6': printf(" sixty");
break;
case'7': printf(" seventy");
break;
case'8': printf(" eighty");
break;
case '9':printf(" ninty");
break;
}


switch(n[3])
{ case '0':
break;
case '1':
printf("one");
getch();
exit(0);
case '2':
printf("two");
getch();
exit(0);
case '3':
printf("three");
getch();
exit(0);
case '4':
printf("four");
getch();
exit(0);
case '5':
printf("five");
getch();
exit(0);
case '6':
printf("six");
getch();
exit(0);
case '7':
printf("seven");
getch();
exit(0);
case '8':
printf("eight");
getch();
exit(0);
case '9':
printf("nine");
getch();
exit(0);
}
}




getch();
return 0;
}

Is This Answer Correct ?    11 Yes 27 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a (n) algorithm that sorts n distinct integers, ranging in size between 1 and kn inclusive, where k is a constant positive integer. (Hint: Use a kn-element array.)

4453


write a program using virtual function to find the transposing of a square matrix?

2845


Code for Two Classes for Doing Gzip in Memory?

2814


Create a program to read two random data set in two files named data1.txt and data2.txt manifold contains integer numbers, whereas data2.txt file contains the float type numbers. Simpanlahmasing each into 2 pieces of data that is an array of type integer array and an array of type float, then calculate the average numbers in the second array.

2152


1+1/2!+1/3!+...+1/n!

1945






write a function that reverse the elements of an array in place.The function must accept only one pointer value and return void.

3958


Ask the user to input three positive integers M, N and q. Make the 2 dimensional array of integers with size MxN, where all the elements of I (I = 1,…,M) line will be members of geometrical progression with first element equal to the number of line (I) and denominator q.

3397


Question 1: Implement a base class Appointment and derived classes Onetime, Daily, Weekly, and Monthly. An appointment has a description (for example, “see the dentist”) and a date and time. Write a virtual function occurs_on(int year, int month, int day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, you must check whether the day of the month matches. Then fill a vector of Appointment* with a mixture of appointments. Have the user enter a date and print out all appointments that happen on that date. *This Should Be Done IN C++

552


Implement a command console for changing settings on a particular object. The command console should allow you to enter a string and will return the response (very similar to a terminal session). The commands are as follows: SET propertyname=newvalue will change the target object’s member named “propertyname” to have a value equal to “newvalue”. If the input value is incompatible (i.e. an int being set to a string), print out an appropriate error message. GET propertyname will print out the current value of the target object’s member named “propertyname”. GET * will print out a list of all target object members and their current values. The system should be extensible for future commands and should accept an arbitrary object, such that another developer could insert another object into the system and rely on the command console to get and set the properties correctly.

3398


how to write a program that opens a file and display in reverse order?

2567


Teta-Omeg-Big-Oh Show that f(n) = n2 + 3n3 is ;(n3).

3193


write a program to perform generic sort in arrays?

2627


A suduco given & u hv 2 check if it is incomplete(blanks left),or correct or incorrect

2407


write a program that reads a series of strings and prints only those strings begging with letter "b"

2674


Given a table of the form: Product Sold on A 1/1/1980 B 1/1/1980 C 1/1/1980 A 1/1/1980 B 1/1/1980 C 2/1/1980 A 2/1/1980 There are 30 products and 10,000 records of such type. Also the month period during which sales happened is given to u. Write the program to display the result as: Product Month No. of copies A January 12 A February 15 A March 27 B January 54 B February 15 B March 10 C January 37

2195