main()
{
int num,number;
char ch;
while(1)
{
clrscr();
printf("\nEnter any number between 0 to 1000 :-\nNumber = ");
scanf("%d",&number);
num=number;
z: if(num<=10 && num>0)
{
if(num==1) printf("One"); if(num==2) printf("Two");
if(num==3) printf("Three"); if(num==4) printf("Four");
if(num==5) printf("Five"); if(num==6) printf("Six");
if(num==7) printf("Seven"); if(num==8) printf("Eight");
if(num==9) printf("Nine"); if(num==10) printf("Ten");
}
y:if(num>10 && num<20)
{
if(num==11) printf("Eleven"); if(num==12) printf("Twelve");
if(num==13) printf("Thirteen"); if(num==14) printf("Fourteen");
if(num==15) printf("Fifteen"); if(num==16) printf("Sixteen");
if(num==17) printf("Seventeen"); if(num==18) printf("Eighteen");
if(num==19) printf("Ninteen");
}
if(num>=20 && num<100)
{
if(num>=20 && num<30)
{
num=num%10;
printf("Twenty ");
goto z;
}
if(num>=30 && num<40)
{
num=num%10;
printf("Thirty ");
goto z;
}
if(num>=40 && num<50)
{
num=num%10;
printf("Forty ");
goto z;
}
if(num>=50 && num<60)
{
num=num%10;
printf("Fifty ");
goto z;
}
if(num>=60 && num<70)
{
num=num%10;
printf("Sixty ");
goto z;
}
if(num>=70 && num<80)
{
num=num%10;
printf("Seventy ");
goto z;
}
if(num>=80 && num<90)
{
num=num%10;
printf("Eighty ");
goto z;
}
if(num>=90 && num<100)
{
num=num%10;
printf("Ninty ");
goto z;
}
}
if(num>=100 && num<1000)
{
if(num/100==1)
{
printf("One Hundred and ");
num=num%100;
goto y;
}
if(num/100==2)
{
printf("Two Hundred and ");
num=num%100;
goto y;
}
if(num/100==3)
{
printf("Three Hundred and ");
num=num%100;
goto y;
}
if(num/100==4)
{
printf("Four Hundred and ");
num=num%100;
goto y;
}
if(num/100==5)
{
printf("Five Hundred and ");
num=num%100;
goto y;
}
if(num/100==6)
{
printf("Six Hundred and ");
num=num%100;
goto y;
}
if(num/100==7)
{
printf("Seven Hundred and ");
num=num%100;
goto y;
}
if(num/100==8)
{
printf("Eight Hundred and ");
num=num%100;
goto y;
}
if(num/100==9)
{
printf("Nine Hundred and ");
num=num%100;
goto y;
}
}
printf("\nPress any key for exit or \"C\" for Continue");
ch=getch();
switch(ch)
{
case 'c':
case 'C': break;
default: exit(0);
}
}
}
Output
No comments:
Post a Comment