I tried the following:
Code:
/* a function that tests whether an integer is even, returning a true or false
answer */
#include <iostream>
using namespace std;
int evenTest(int);
int main()
{
int n = 0;
cout << "Enter a number: ";
cin >> n;
cout << evenTest(n) << endl;
return 0;
}
int evenTest(int n)
{
if (n % 2 == 0)
cout << n << " is even" << endl;
else
cout << n << " is odd" << endl;
}
It generates the following output:
Code:
Enter a number: 10
10 is even
98476
Why is 98476 generated?
Also, Polymorphic OOP, how would I implement Value & 1 ?