write a c code "if you give a any decimal number then print that number in english alphabet"?

ex: i/p: 552
o/p: five hundred fifty two ...

Answer Posted / baluusa8

#include<stdio.h>
void main()
{
int number,i=0,j,digit;
char * word[1000];
printf("Enter number
");
scanf("%d",&number);
while(number){

digit = number %10;
number = number /10;

switch(digit){
case 0: word[i++] = "zero"; break;
case 1: word[i++] = "one"; break;
case 2: word[i++] = "two"; break;
case 3: word[i++] = "three"; break;
case 4: word[i++] = "four"; break;
case 5: word[i++] = "five"; break;
case 6: word[i++] = "six"; break;
case 7: word[i++] = "seven"; break;
case 8: word[i++] = "eight"; break;
case 9: word[i++] = "nine"; break;

}
}

for(j=i-1;j>=0;j--){
printf("%s ",word[j]);
}
}

Is This Answer Correct ?    1 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you mean by c?

584


Explain what is the difference between far and near ?

649


Are bit fields portable?

671


Are negative numbers true in c?

595


What are the benefits of organizational structure?

568






HOW TO SOLVE A NUMERICAL OF LRU IN OS ??????

2263


PROGRAM TO WRITE CONTENTS OF 1 FILE IN REVERSE TO ANOTHER FILE,PROGRAM TO COPY 1 FILE TO ANOTHER BY SPECIFYING FILE NAMES AS COMMAND LINE

1464


Can math operations be performed on a void pointer?

583


Why can arithmetic operations not be performed on void pointers?

584


Write a program to reverse a given number in c?

595


What is multidimensional arrays

624


What functions are used in dynamic memory allocation in c?

593


What are the general description for loop statement and available loop types in c?

685


Explain what is the concatenation operator?

622


Is c pass by value or reference?

593