-
Notifications
You must be signed in to change notification settings - Fork 0
/
num.c
80 lines (80 loc) · 1.47 KB
/
num.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include<stdio.h>
#include<string.h>
int a,rem,temp,rem2;
char str[50][15]={"zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty","thirty","fourty","fifty","sixty","seventy","eighty","ninety","hundred"};
void num(int a)
{
if(a<=20)
puts(str[a]);
else if(a>20&&a<30)
{
printf(str[20]);
rem=a%10;
printf(" ");
printf("%s",str[rem]);
}
else if(a>=30&&a<40)
{
printf(str[21]);
rem=a%10;
printf(" ");
printf("%s",str[rem]);
}
else if(a>=40&&a<50)
{
printf(str[22]);
rem=a%10;
printf(" ");
printf("%s",str[rem]);
}
else if(a>=50&&a<60)
{
printf(str[23]);
rem=a%10;
printf(" ");
printf("%s",str[rem]);
}
else if(a>=60&&a<70)
{
printf(str[24]);
rem=a%10;
printf(" ");
printf("%s",str[rem]);
}
else if(a>=70&&a<80)
{
printf(str[25]);
rem=a%10;
printf(" ");
printf("%s",str[rem]);
}
else if(a>=80&&a<90)
{
printf(str[26]);
rem=a%10;
printf(" ");
printf("%s",str[rem]);
}
else if(a>=90&&a<100)
{
printf(str[27]);
rem=a%10;
printf(" ");
printf("%s",str[rem]);
}
}
void main()
{
printf("enter the number between 0 and 999\n");
scanf("%d", &a);
if(a<100)
num(a);
else if(a>=100&&a<=999)
{
printf("%s",str[a/100]);
printf(" ");
printf(str[28]);
printf(" and ");
num(a%100);
}
}