Write A Program for printing a number in words

#include<stdio.h> #include<conio.h> void main ( ) { int n, s, r = 0; r1 = 0; printf (“enter a number”); scanf (“%d...

#include<stdio.h>
#include<conio.h>
void main ( )
{
int n, s, r = 0; r1 = 0;
printf (“enter a number”);
scanf (“%d", & n);
while ( n!=0)
{
   s = n % 10;
   r = r * 10 + s;
   n = n/10;
}
while ( r!=0)
{
  r1 = r%10;
 switch ( r1)
{
case 0 : printf ( “\t zero”);
              break;
case 1 : printf ( “\t one”); 
              break;
case 2 : printf ( “\t two”);
              break;
case 3 : printf ( “\t three");
              break;
case 4 : printf ( “\t four");
              break;
case 5 : printf ( “\t five");
              break;
case 6 : printf ( “\t six"); 
              break;
case 7 : printf ( “\t seven");
              break;
case 8 : printf ( “\t eight");
              break;
case 9 : printf ( “\t nine”); 
              break;
}
r = r/10;
}
getch ( );
}

Out Put:

enter a number 488
four eight eight

Related

C Programs 5313586945787776672

Post a Comment

emo-but-icon

item