Program to change an integer to words
Program:
#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;
case 9 :
printf("NINE ");
break;
}
}
getch();
}
Output:
Enter a number : 225589
TWO TWO FIVE FIVE EIGHT NINE
-
UpdatedDec 30, 2019
-
Views5,023
You May Like
Program to maintain employee details using structures
Program to maintain student details using structures
Check whether the person is eligible to vote or not
Print the numbers that are divisible by a given no.
Program to generate magic square
To sort the given numbers in ascending & descending order