-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathif-div_1.c
102 lines (87 loc) · 1.12 KB
/
if-div_1.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
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int div2(int *n)
{
int d;
int *b = n;
int c = *b;
d = c / 2;
return (d);
}
int div3(int *n)
{
int d;
int *b = n;
int c = *b;
d = c / 3;
return (d);
}
int div5(int *n)
{
int d;
int *b = n;
int c = *b;
d = c / 5;
return (d);
}
int div7(int *n)
{
int d;
int *b = n;
int c = *b;
d = c / 7;
return (d);
}
/*int *toArray(int n)
{
int m = n;
int digit = 0;
while (m)
{
digit++;
m /= 10
}
char* arr;
char arr1[digit];
arr = (char*)malloc(digit);
int index = 0;
while (n)
{
arr1[++index] = n % 10 + '0';
n /= 10;
}
int i;
for (i = 0; i < index; i++)
{
arr[i] = arr1[index - i];
}
arr[i] = '\0';
return (char*) arr;
}*/
int main()
{
int n;
n = 17115;
printf("size of n :%ld\n", sizeof(n));
/*printf("string of n:%ld", strlen(toArray));*/
if(n % 2 == 0)
{
printf("%d = %d * 2\n",n ,div2(&n));
}
if(n % 3 == 0)
{
printf("%d = %d * 3\n",n ,div3(&n));
}
if(n % 5 == 0)
{
printf("%d = %d * 5\n",n ,div5(&n));
}
if(n % 7 == 0)
{
printf("%d = %d * 7\n",n ,div7(&n));
}
else
printf("Try again\n");
return (0);
}