-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnum2words.c
More file actions
24 lines (22 loc) · 718 Bytes
/
Copy pathnum2words.c
File metadata and controls
24 lines (22 loc) · 718 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <stdio.h>
#include <string.h> //taught in cs50x used strlen
int main() {
char num[50];
printf("Enter a number: ");
scanf("%s", num);
for (int i = 0; i < strlen(num); i++) {
switch (num[i]) {
case '0': printf("zero "); break;
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;
}
}
return 0;
}