Last active
January 21, 2017 21:33
-
-
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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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