Create a program that determine if a number is divisible by 2, 3 and 5. BEWARE:
ID: 3542042 • Letter: C
Question
Create a program that determine if a number is divisible by 2, 3 and 5. BEWARE: a number is divisible by the other only when the remaining residue is 0
Example 1:
Enter a number: 10
cout<< 10 is divisible by 2
cout<< 10 [ IS NOT ] is divisible by 3
cout<< 10 is divisible by 5
Example 2:
Enter a number: 15
cout<<15 [ IS NO T] divisible by 2
cout<<15 is divisible by 3
cout<<15 is divisible by 5
Example 3:
Enter a number: 7
cout<< 7 [ IS NO T] divisible by 2
cout<< 7 [ IS NO T] divisible by 3
cout<< 7 [ IS NO T] divisible by 5
Explanation / Answer
please rate - thanks
any changes needed, I'll make them
I assumed no functions
#include <iostream>
using namespace std;
int main()
{int n;
cout<<"Enter a number: ";
cin>>n;
if(n%2==0)
cout<<n<<" is divisible by 2 ";
else
cout<<n<<" is [IS NOT] divisible by 2 ";
if(n%3==0)
cout<<n<<" is divisible by 2 ";
else
cout<<n<<" is [IS NOT] divisible by 2 ";
if(n%5==0)
cout<<n<<" is divisible by 5 ";
else
cout<<n<<" is [IS NOT] divisible by 5 ";
system("pause");
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.