-
Notifications
You must be signed in to change notification settings - Fork 337
/
FIND_EVEN_ AND_DIVISIBLE_BY_3.c
75 lines (65 loc) · 1.05 KB
/
FIND_EVEN_ AND_DIVISIBLE_BY_3.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
#include <stdio.h>
#define MAX 5
int main()
{
int i,j = 0,num[MAX];
printf("Enter numbers in the range of 1 to 9 \n");
for(i = 0; i<MAX; )
{
scanf("%d",&num[i]);
switch (num[i])
{
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9: i++;
break;
default:
{
j = 1;
break;
}
}
if(j == 1)
{
printf("NO MORE INPUT");
break;
}
}
printf("Multiple of 3's \n\n");
printMultiple(num, i);
printf("\n\n\n");
printf("EVEN numbers\n\n\n");
printEven(num, i);
}
printMultiple(int num[MAX], int len)
{
int i,j,k;
for(i = 0; i<len; i++)
{
int ans3 = num[i]%3;
switch (ans3)
{
case 0:
printf("%d \n", num[i]);
}
}
}
printEven(int num[MAX], int len)
{
int i,j,k;
for(i = 0; i<len; i++)
{
int ans_even = num[i]%2;
switch (ans_even)
{
case 0:
printf("%d \n", num[i]);
}
}
}