-
Notifications
You must be signed in to change notification settings - Fork 0
/
number-into-equivalent-word.c
124 lines (120 loc) · 2.79 KB
/
number-into-equivalent-word.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include <stdio.h>
int main(void) {
int number;
int digit1;
int digit2;
printf("Enter a two-digit number: ");
scanf("%d", &number);
digit1 = number / 10;
digit2 = number % 10;
if(number >= 100)
{
printf("Number you entered doesn't have two digits!");
return 0;
}
printf("You entered the number: ");
if (number == 10) {
printf("ten");
}
if (digit1 == 1) {
switch (digit2) {
case 1:
printf("eleven");
break;
case 2:
printf("twelve");
break;
case 3:
printf("thirteen");
break;
case 4:
printf("fourteen");
break;
case 5:
printf("fifteen");
break;
case 6:
printf("sixteen");
break;
case 7:
printf("seventeen");
break;
case 8:
printf("eighteen");
break;
case 9:
printf("nineteen");
break;
default:
break;
}
} else if (digit1 > 1) {
switch (digit1) {
case 2:
printf("twenty");
break;
case 3:
printf("thirty");
break;
case 4:
printf("forty");
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:
break;
}
if (digit2 == 0) {
return 0;
} else
printf("-");
switch (digit2) {
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:
break;
}
}
return 0;
}
//
// Created by konket on 03/10/2022.
//