Hey again, I was hoping someone here could look at my code and tell me why I'm not receiving the correct output.
Here's what I'm supposed to do:Write a program that asks a user to enter an integer, say n,then list all the numbers that are less than or equal to n and can be divided by both 2 and 7
#include<iostream>
using namespace std;
int main()
{
int n;
cout << "Please enter an integer: " << endl;
cin>>n;
for( int i = 0; i <= n; i++ )
cout << i << endl;
if( n/2 && n/7 )
cout << "The integer you entered is divisible by 2 and 7" <<endl;
else
cout << "The integer you entered is not divisible" << endl;
return 0;
}
When I run the program it will show all the numbers less than the integer I entered. However when it comes to finding out if the number is divisible by 2 and 7, no matter what number I enter it says it's divisible by 2 and 7.
If someone could show me what I'm doing wrong i'd appreciate it.