This should be real easy but I'm not getting it.
User is prompted for an integer. I test the integer for being equal to zero or int % 1 !=0. Below I test against mod 2 for even/odd.
First it thinks everything is an odd integer. Second it thinks everything is odd. I thought % just gives you the remainder of the one figure divided by the other. Am I missing something?
fyi: the only reason for the bool is because I tried the test with just the % and got the same result. Any help?Code:#include <iostream> #include <iomanip> using namespace std; int main() { int num = 0; bool isOdd; cout << "Enter an integer (whole number) and I will tell you" << endl; cout << "if the number is odd or even: " << endl; cin >> num; if(num=0 || num % 1 != 0) { cout << "Not an integer. Shutting down." << endl; } if(num%2!=0) { isOdd = true; } if(isOdd=true) { cout << "Number is Odd." << endl; } if(isOdd=false) { cout << "Number is even." << endl; } system ("pause"); }