#include<stdio.h>
#include<conio.h>
void fun(int);
void fun1(int);
void fun2(int);
main()
{
int a,b,c,d,e,f,g,n;
clrscr();
a=b=c=d=e=f=g=0;
printf("Enter a no.");
scanf("%d",&n);
if((a=n/1000)>0)
{
//printf("%d",a);
if((b=a/10)>0)
{
fun1(b);
//fun((a%10));
}
fun((a%10));
printf(" thousand ");
}
c=n%1000;
if((d=c/100)>0)
{
fun(d);
printf(" hundred ");
}
e=c%100;
if(e>=10 && e<=19)
fun2(e);
else
{
if((f=e/10)>0)
{
fun1(f);
}
if((g=e%10)>0)
{
fun(g);
}
}
getch();
return 0;
}
void fun(int i)
{
switch(i)
{
case 0:
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;
default:
printf("nothing ");
break;
}
}
void fun1(int i)
{
switch(i)
{
case 0:
break;
case 1:
printf("one ");
break;
case 2:
printf("twenty ");
break;
case 3:
printf("thirty ");
break;
case 4:
printf("fourty ");
break;
case 5:
printf("fifty ");
break;
case 6:
printf("sixty ");
break;
case 7:
printf("seventy ");
break;
case 8:
printf("eighty ");
break;
case 9:
printf("ninety ");
break;
default:
printf("nothing ");
break;
}
}
void fun2(int i)
{
switch(i)
{
case 10:
printf("ten");
break;
case 11:
printf("elaone ");
break;
case 12:
printf("twelve ");
break;
case 13:
printf("thirteen ");
break;
case 14:
printf("fourteen ");
break;
case 15:
printf("fifteen ");
break;
case 16:
printf("sixteen ");
break;
case 17:
printf("seventeen ");
break;
case 18:
printf("eighteen ");
break;
case 19:
printf("nineteen ");
break;
default:
printf("nothing ");
break;
}
}
Out Put:
Enter a no: 9531
nine thousand five hundred thirty one
#include<conio.h>
void fun(int);
void fun1(int);
void fun2(int);
main()
{
int a,b,c,d,e,f,g,n;
clrscr();
a=b=c=d=e=f=g=0;
printf("Enter a no.");
scanf("%d",&n);
if((a=n/1000)>0)
{
//printf("%d",a);
if((b=a/10)>0)
{
fun1(b);
//fun((a%10));
}
fun((a%10));
printf(" thousand ");
}
c=n%1000;
if((d=c/100)>0)
{
fun(d);
printf(" hundred ");
}
e=c%100;
if(e>=10 && e<=19)
fun2(e);
else
{
if((f=e/10)>0)
{
fun1(f);
}
if((g=e%10)>0)
{
fun(g);
}
}
getch();
return 0;
}
void fun(int i)
{
switch(i)
{
case 0:
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;
default:
printf("nothing ");
break;
}
}
void fun1(int i)
{
switch(i)
{
case 0:
break;
case 1:
printf("one ");
break;
case 2:
printf("twenty ");
break;
case 3:
printf("thirty ");
break;
case 4:
printf("fourty ");
break;
case 5:
printf("fifty ");
break;
case 6:
printf("sixty ");
break;
case 7:
printf("seventy ");
break;
case 8:
printf("eighty ");
break;
case 9:
printf("ninety ");
break;
default:
printf("nothing ");
break;
}
}
void fun2(int i)
{
switch(i)
{
case 10:
printf("ten");
break;
case 11:
printf("elaone ");
break;
case 12:
printf("twelve ");
break;
case 13:
printf("thirteen ");
break;
case 14:
printf("fourteen ");
break;
case 15:
printf("fifteen ");
break;
case 16:
printf("sixteen ");
break;
case 17:
printf("seventeen ");
break;
case 18:
printf("eighteen ");
break;
case 19:
printf("nineteen ");
break;
default:
printf("nothing ");
break;
}
}
Out Put:
Enter a no: 9531
nine thousand five hundred thirty one
No comments:
Post a Comment