Write a program in c to input a 5 digit number and print it
in words.
Answer Posted / rakesh.bit
# include <stdio.h>
int main ()
{
int n,temp,t,s=0,i,ctr=0;
char a[10][10] = {"zero", "one", "two", "three", "four",
"five", "six", "seven", "eight", "nine"};
printf ("Enter the number:\n");
scanf ("%d", &n);
//printf ("The given num in word = %s\n", a[n]);
t=n;
while(n>0)
{
ctr++;
n=n/10;
}
while(t>0)
{
temp=t%10;
s=10*s+temp;
t=t/10;
}
for(i=0;i<ctr;i++)
{
printf("%s",a[s%10]);
s=s/10;
}
}
| Is This Answer Correct ? | 22 Yes | 16 No |
Post New Answer View All Answers
What is the purpose of scanf() and printf() functions?
What is the time and space complexities of merge sort and when is it preferred over quick sort?
Why main is used in c?
How can I generate floating-point random numbers?
What are valid operations on pointers?
write a C program: To search a file any word which starts with ?a?. If the word following this ?a? starts with a vowel.Then replace this ?a? with ?a? with ?an?. redirect with the output onto an output file.The source file and destination file are specified by the user int the command line.
What is typedef?
Calculate 1*2*3*____*n using recursive function??
I need a sort of an approximate strcmp routine?
Explain what are binary trees?
How can I handle floating-point exceptions gracefully?
What is the total generic pointer type?
What are the types of pointers?
What does the c in ctime mean?
What are the advantages of using linked list for tree construction?