Write a program in c to input a 5 digit number and print it
in words.
Answer Posted / mayank
/*write a program to accept any number up to five digits and
print that in words(without using array). for example- 1265=
one two six five*/
#include<stdio.h>
#include<stdlib.h>
main()
{
int x,mod, rev=0;
printf("enter number(up to five digits)");
scanf("%d", &x);
if(x>99999)
{
printf("invalid number");
exit(0);
}
while(x>0)
{
mod=x%10;
rev=rev*10+mod;
x=x/10;
}
while(rev>0)
{
mod=rev%10;
switch(mod)
{
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;
}
rev=rev/10;
}
printf("\n");
}
| Is This Answer Correct ? | 30 Yes | 12 No |
Post New Answer View All Answers
hw can we delete an internal node of binary search tree the internal node has child node..plz write progarm
What is call by value in c?
What is difference between Structure and Unions?
How to check whether string is a palindrome, WITHOUT USING STRING FUNCTIONS?
Write a progarm to find the length of string using switch case?
What is derived datatype in c?
What is a dynamic array in c?
How to delete a node from linked list w/o using collectons?
A float occupies 4 bytes in memory. How many bits are used to store exponent part? since we can have up to 38 number for exponent so 2 ki power 6 6, 6 bits will be used. If 6 bits are used why do not we have up to 64 numbers in exponent?
What does %2f mean in c?
Where define directive used?
Explain threaded binary trees?
What are the advantages and disadvantages of a heap?
pgm to find number of words starting with capital letters in a file(additional memory usage not allowed)(if a word starting with capital also next letter in word is capital cann't be counted twice)
Why can’t we compare structures?