This is a C program for converting a number to its textual equivalent. Output as.
23 - two three.
This is a part of Mumbai University MCA College C program MCA Sem 1
#include<stdio.h>
void pw(long); //function
char *unit[]={" zero"," one"," two"," three"," four"," five"," six"," seven"," eight"," nine"};
void main()
{
long n,x=100000000;
printf("Enter upto 9 digit number\n");
scanf("%ld",&n);
if(n<=0)
printf("Enter a positive number\n");
else
{
//This will truncate zeros at start if any and if not present then set value of x appropriately
while(((n/x)%10)==0)
x=x/10;
//Actual logic to print words starts here
while(x>0)
{
pw((n/x)%10);
x/=10;
}
}
}
void pw(long n)
{
printf("%s",unit[n]);
}
Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.
No comments:
Post a Comment