- #1
ineedhelpnow
- 651
- 0
Write an expression that will print "Even" if the value of userNum is an even number.
the <STUDENT CODE> is
i understand the %2 part but why equal to 0? how does the ==0 part detect that its an even number?
Code:
#include <iostream>
using namespace std;
int main() {
int userNum = 0;
userNum = 6;
if (<STUDENT CODE>) {
cout << "Even" << endl;
}
else {
cout << "Odd" << endl;
}
return 0;
}
the <STUDENT CODE> is
Code:
userNum %2==0
i understand the %2 part but why equal to 0? how does the ==0 part detect that its an even number?