In: Computer Science
Write a program in Objective C that takes an integer keyed in from the terminal and extracts and displays each digit of the integer in Eglish. So if the user types 647, the program should display the following:
six
four
seven
C program to convert the number into words
Source Code:
#include<stdio.h>
#include<stdlib.h>
int main(){
long int n,sum=0,m;
printf("enter the number :");
scanf("%ld",&n);
while(n>0)
{
m=n%10;
sum=sum*10+m;
n=n/10;
}
n=sum;
while(n>0)
{
m=n%10;
switch(m)
{
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;
case 0:
printf("zero ");
break;
default:
printf("tttt");
break;
}
n=n/10;
}
return 0;
}
The output