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



write a program that accepts a number and outputs its equivalent in words. take note that the max..

Answer / 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

More C++ Code Interview Questions

A string of charaters were given. Find the highest occurance of a character and display that character. eg.: INPUT: AEGBCNAVNEETGUPTAEDAGPE OUTPUT: E

1 Answers  


how to find out the maximum number out of the three inputs.

6 Answers   ABC, Apple, C3I, HP, TCS,


write a program that prompt the user to enter his height and weight,then calculate the body mass index and show the algorithm used

0 Answers   Jomo Kenyatta University,


hello friends, given an expression we have to remove the unwanted brackets in that expression. Eg : (a+b) ---> a+b (a+b)*(c)-----> (a+b)*c. Please mail me if you know the logic. My mail id is : saravana6m@gmail.com. Thank you in advance :-)

1 Answers   GrapeCity, Microsoft,


What will be the output- for(i=1;i<=3;i++) { printf("%d",i); continue; i++; }

5 Answers   Impetus,






Write a function- oriented to convert the input dollar(s) into its equivalent peso. Assume that one dollar is equivalent to 51.60

1 Answers  


Algorithm in O(2n) Presently we can solve in our hypothetical machine problem instances of size 100 in 1 minute using algorithm A, which is a O(2n). We would like to solve instances of size 200 in 1 minute using algorithm A on a new machine. What is the speed of the new machine should be?

2 Answers   ABC, Qatar University,


write a program to perform generic sort in arrays?

0 Answers  


Deriving time complexity of Binary tree and AVL tree, step by step.

4 Answers   NetApp,


a program using one dimensional array that searches a number if it is found on the list of given input numbers given by the user and locate its exact location in the list.. ""EXAMPLE"" enter how many numbers to be inputted: 5 12 14 11 09 30 what number to search: 11 11 IS FOUND IN LOCATION 3 PLZZZ.. ELP ME...

3 Answers  


Write a C/C++ program that connects to a MySQL server and displays the global TIMEZONE.

0 Answers   Facebook, Webyog, Wipro,


. Remove all the blank spaces between character.Matrix is of 10* 10. eg: INPUT ------------------------------------ | N | A | | V | |T ------------------------------------- | |G | U | |P | -------------------------------------- |T | | | A | | ------------------------------------ OUTPUT: ------------------------------------ | N | A | V | T | | ------------------------------------- |G |U | P | | | -------------------------------------- |T | A | | | | ------------------------------------

2 Answers   Nagarro,


Categories