Coding:
#include<stdio.h>
#include<conio.h>
void pw(long,char[]);
char *one[]={" ",
" One"," Two"," Three"," Four",
" Five"," Six"," Seven"," Eight",
" Nine"," Ten"," Eleven"," Twelve",
" Thirteen"," Fourteen"," Fifteen",
" Sixteen"," Seventeen"," Eighteen",
" Nineteen"
};
char *ten[]={ " "," "," Twenty"," Thirty"," Forty",
" Fifty"," Sixty","Seventy"," Eighty",
" Ninety"
};
void main()
{
long n;
clrscr();
printf("\n\n Enter any 9 digit no: ");
scanf("%ld",&n);
printf("\n");
if(n<=0)
printf("Enter numbers greater than 0");
else
{
pw((n/10000000),"Crore");
pw(((n/100000)%100),"Lakh");
pw(((n/1000)%100),"Thousand");
pw(((n/100)%10),"Hundred");
pw((n%100)," ");
}
getch();
}
void pw(long n,char ch[])
{
textcolor(YELLOW);
(n>19)?cprintf("%s %s ",ten[n/10],one[n%10]):cprintf("%s ",one[n]);
if(n)
cprintf("%s ",ch);
}
Output:
No comments:
Post a Comment