-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexercise-5-6.c
64 lines (56 loc) · 1.06 KB
/
exercise-5-6.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
#include <stdio.h>
#include <math.h>
int main(void) {
int number;
int tempNumber;
int currentNumber;
int numberLength = 0;
printf("Please enter your number: ");
scanf("%i", &number);
tempNumber = number;
do {
numberLength++;
tempNumber /= 10;
} while (tempNumber != 0);
for (int i = numberLength; i > 0; i--) {
tempNumber = number;
tempNumber /= pow(10, i - 1);
currentNumber = tempNumber % 10;
switch(currentNumber) {
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;
case 0:
printf("zero ");
break;
default:
break;
}
}
printf("\n");
return 0;
}