//Title: Set6Exercises
//Author: MacLeight
//Date: 21 October 2012
//Write a function called OddCheck that takes one integer as an argument.
//The function should return a 1 if the number is odd and a 0 if it is even.
#include <iostream>
usingnamespace std;
int OddCheck ( int iNum )
{
int iCheck = iNum % 2;
if (iCheck == 0)
iCheck = 0;
elseif (iCheck != 0)
iCheck = 1;
return iCheck;
}
int main (void)
{
int iNum = 0;
cout << "Enter a number to check." << endl;
cin >> iNum;
cout << OddCheck (iNum) << endl;
return 1;
}
Is there a better way? More concise, easier to read, anything?