-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdigittoalpha.c
More file actions
71 lines (69 loc) · 1.68 KB
/
Copy pathdigittoalpha.c
File metadata and controls
71 lines (69 loc) · 1.68 KB
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
#include <stdio.h>
int main()
{
int number;
int reminder;
int divisor = 1;
printf("Enter your number\n");
scanf("%d", &number);
int temp = number;
if (number == 0)
{
printf("ZERO\n");
return 0; // Terminate the program here as per requirements
}
else
{
while (number / divisor >= 10)
{
divisor = divisor * 10; // To get the suitable divisor for any kind of number using this loop
}
while (divisor > 0)
{
int digit = temp / divisor; // to get the first digit of the number
temp = temp % divisor; // to terminate the first digit
divisor = divisor / 10; // We have to delete the divisor as well
if (digit == 0)
{
printf("Zero ");
}
else if (digit == 1)
{
printf("One ");
}
else if (digit == 2)
{
printf("Two ");
}
else if (digit == 3)
{
printf("Three ");
}
else if (digit == 4)
{
printf("Four ");
}
else if (digit == 5)
{
printf("Five ");
}
else if (digit == 6)
{
printf("Six ");
}
else if (digit == 7)
{
printf("Seven ");
}
else if (digit == 8)
{
printf("Eight ");
}
else if (digit == 9)
{
printf("Nine ");
}
}
}
return 0;
}