Wednesday 11 July 2012

/* Program to change an integer to words - NUMTOWD.C */


# include <stdio.h>
# include <conio.h>
void main()
{
long n, a[10], i, c = 0 ;
clrscr() ;
printf("Enter a number : ") ;
scanf("%ld", &n) ;
while(n > 0)
{
a[c] = n % 10 ;
n = n / 10 ;
c++ ;
}
printf("\n") ;
for(i = c - 1 ; i >= 0 ; i--)
{
switch(a[i])
{
case 0 :
printf("ZERO ") ;
break ;
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 ;
B.Bhuvaneswaran A.45
case 9 :
printf("NINE ") ;
break ;
}
}
getch() ;
}
RUN 1 :
~~~~~~~
Enter a number : 225589
TWO TWO FIVE FIVE EIGHT NINE

No comments:

Post a Comment

What is Map Collection?

A map collection refers to a set of maps that are compiled and organized for a specific purpose, such as research, education, or preservatio...