Q:

Write a C++ program to check if a given positive number is a multiple of 3 or a multiple of 7

0

Write a C++ program to check if a given positive number is a multiple of 3 or a multiple of 7

Sample Output:

1
1
1
0

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <iostream>
using namespace std;

bool test(int n)
        {
            return n % 3 == 0 || n % 7 == 0;
        }
        
int main() 
 {
  cout << test(3) << endl;  
  cout << test(14) << endl;  
  cout << test(12) << endl;  
  cout << test(37) << endl;  
  return 0;    
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now