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


Please Help Members By Posting Answers For Below Questions

Explain what are binary trees?

601


How do you list files in a directory?

553


What are qualifiers and modifiers c?

537


What is atoi and atof in c?

610


When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd

635






What are Macros? What are its advantages and disadvantages?

631


What is the c value paradox and how is it explained?

567


Are global variables static in c?

663


What is getche() function?

599


What are preprocessor directives in c?

627


What is the difference between malloc() and calloc() function in c language?

589


Differentiate between Macro and ordinary definition.

717


What is exit() function?

555


Where can I get an ansi-compatible lint?

633


How many levels deep can include files be nested?

642