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 operator precedence?
Why is c called c not d or e?
How can my program discover the complete pathname to the executable from which it was invoked?
Tell me when would you use a pointer to a function?
What is data structure in c programming?
Explain how can you tell whether two strings are the same?
How a string is stored in c?
What are structure members?
Can a variable be both const and volatile?
what is recursion in C
How do I send escape sequences to control a terminal or other device?
What are structures and unions? State differencves between them.
Explain how can I convert a string to a number?
What is pass by reference in functions?
WRITE A PROGRAM TO MERGE TWO SORTED ARRAY USING MERGE SORT TECHNIQUE..