Skip to content

Instantly share code, notes, and snippets.

@lnrsoft
Last active January 21, 2017 21:33
Show Gist options
  • Save lnrsoft/9082039 to your computer and use it in GitHub Desktop.
Save lnrsoft/9082039 to your computer and use it in GitHub Desktop.
There is a simple method to determinate whether a number is even or odd in C++
// This source code written by Roland Ihasz
#include<iostream>
using namespace std;
bool evenOrOdd(int integer)
{
if (integer % 2==0)
return true;
else
return false;
}
int main()
{
int number;
cout << "Enter an integer value: ";
cin >> number;
if(evenOrOdd(number) == true)
cout << number << " is an even number." << endl;
else
cout << number << " is an odd number." << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment