/****************************
* Is the number even or odd *
* By Frank Henderson *
* 12.29.11 2:29 am *
****************************/
#include <iostream>
using namespace std;
int main()
{
int n, remainder;
// Get a number from the user, if the user enters anything but a whole number, print error message
cout << "\nEnter a number and press ENTER: ";
cin >> n;
if (n != (n / 2))
cout << "You must enter whole numbers only, try again";
// Get remainder after dividing by 2
remainder = n % 2;
// If the remainder is 0, the number input is even
if (remainder == 0)
cout << "The number is even" << endl << endl;
else
cout << "The number is odd" << endl << endl;
return 0;
}


Sign In
Create Account

Back to top









