Programming Problem I ( class, stack, Linked list )
You are required to find out whether the number entered by user have length even or odd. You cannot use the modulus function, modulus operator or length function
#include <iostream>
using namespace std;
// Returns true if a is even otherwise it returns odd
bool isEven(int a)
{
bool isEven = true;
for (int i=1; i <= a; i++)
isEven = !isEven;
return isEven;
}
int main()
{
int a = 101;
isEven(a) ? cout << "Even" : cout << "Odd";
return 0;
}
Comments
Leave a comment