fork download
  1. #include <iostream>
  2.  
  3. void print_divisibility(int value, int divisor) {
  4. bool evenly_divisible = value % divisor == 0;
  5.  
  6. std::cout << value ;
  7. if (evenly_divisible)
  8. std::cout << " is evenly divisible by ";
  9. else
  10. std::cout << " is not evenly divisible by ";
  11.  
  12. std::cout << divisor << '\n' ;
  13.  
  14. }
  15.  
  16. int main() {
  17. int value;
  18. while (std::cin >> value) {
  19. print_divisibility(value, 3);
  20. print_divisibility(value, 7);
  21. }
  22. }
Success #stdin #stdout 0s 3472KB
stdin
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
stdout
1 is not evenly divisible by 3
1 is not evenly divisible by 7
2 is not evenly divisible by 3
2 is not evenly divisible by 7
3 is evenly divisible by 3
3 is not evenly divisible by 7
4 is not evenly divisible by 3
4 is not evenly divisible by 7
5 is not evenly divisible by 3
5 is not evenly divisible by 7
6 is evenly divisible by 3
6 is not evenly divisible by 7
7 is not evenly divisible by 3
7 is evenly divisible by 7
8 is not evenly divisible by 3
8 is not evenly divisible by 7
9 is evenly divisible by 3
9 is not evenly divisible by 7
10 is not evenly divisible by 3
10 is not evenly divisible by 7
11 is not evenly divisible by 3
11 is not evenly divisible by 7
12 is evenly divisible by 3
12 is not evenly divisible by 7
13 is not evenly divisible by 3
13 is not evenly divisible by 7
14 is not evenly divisible by 3
14 is evenly divisible by 7
15 is evenly divisible by 3
15 is not evenly divisible by 7
16 is not evenly divisible by 3
16 is not evenly divisible by 7
17 is not evenly divisible by 3
17 is not evenly divisible by 7
18 is evenly divisible by 3
18 is not evenly divisible by 7
19 is not evenly divisible by 3
19 is not evenly divisible by 7
20 is not evenly divisible by 3
20 is not evenly divisible by 7
21 is evenly divisible by 3
21 is evenly divisible by 7