Commit 86744c886fad357715f59e26d5a029d0948636e6

Authored by Anton Qiu
1 parent 89ff046618
Exists in master

p2 done

Showing 2 changed files with 24 additions and 0 deletions Inline Diff

No preview for this file type

HW3/multiples.c View file @ 86744c8
File was created 1 #include <stdio.h>
2
3 int main() {
4 int i[6];
5 int d3 = 0,
6 d7 = 0,
7 d21 = 0;
8 printf("Six integers: ");
9 scanf("%d %d %d %d %d %d", i, i+1, i+2, i+3, i+4, i+5);
10 for (int j = 0; j < 6; j++) {
11 int each = i[j];
12 if (each % 21 == 0) {
13 d3++; d7++; d21++;
14 }
15 else if (each % 3 == 0) {
16 d3++;
17 }
18 else if (each % 7 == 0) {
19 d7++;
20 }
21 }
22 printf("%d divisible by 3,\n%d divisible by 7,\n%d divisible by both.\n", d3, d7, d21);
23 return 0;