-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnumbers_to_words.c
48 lines (43 loc) · 1.04 KB
/
numbers_to_words.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
#include <stdio.h>
int main()
{
int n, num = 0;
//Reading a number from user
printf("Enter any number to print in words: ");
scanf("%d", &n);
while(n != 0)
{
num = (num * 10) + (n % 10);
n /= 10;
}
while(num != 0)
{
switch(num % 10)
{
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;
case 10:printf("ten");
break;
}
num = num / 10;
}
return 0;
}