#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
void main()
{
long int n;
ldiv_t d;
int level=0;
int num,i;
char t1000[4][20]={"","hezar","milion","miliard"};
char t100[10][20]={"","yeksad","devist","sisad","chaharsad","pansad",
"sheshsad","haftsad","hashtsad","nohsad"};
char t10[10][20]={"dah","yazdah","davazdah","sizdah","chahardah","panzdah",
"shanzdah","defdah","hejdah","noozdah"};
char t20[10][20]={"","","bist","si","chehel","panjah",
"shast","haftad","hashtad","navad"};
char t1[10][20]={"","yek","do","seh","chahar","panj",
"shesh","haft","hasht","noh"};
char s[80],t[80],u[80];
clrscr();
printf ("Please enter a number : ");
scanf ("%ld", &n);
if (n==0)
strcpy(s,"Sefr");
else
{
strcpy(s,"");
do
{
d = ldiv(n,1000L);
num=(int) d.rem;
n=d.quot;
strcpy(t,t100[num / 100]);
i=num % 100;
if ((i >= 10) && (i <= 19))
{
if (t[0])
strcat(t," o ");
strcat(t,t10[i-10]);
}
else
{
if ((t[0]) && (i >= 20))
strcat(t," o ");
strcat(t,t20[i / 10]);
if (i % 10)
{
if (t[0])
strcat(t," o ");
strcat(t,t1[i % 10]);
}
}
if (t[0])
{
if (s[0])
strcpy(u," o ");
else
strcpy(u,"");
strcat(u,s);
strcpy(s,t1000[level]);
strcat(s,u);
strcat(t,s);
strcpy(s,t);
}
level++;
} while (n);
}
printf ("%s",s);
getch();
}