How to Find Even Odd Number using Function

By | February 8, 2013
odd-even-numberQuestion: Write a program containing a function called as even_odd() which determines whether the number entered is even or odd.
In this program to determine the value is Odd or Even.  In this program you can easily find odd or even number using function. I am sure the following coding is much better method, so I am posting here before I write out the same long winded method in yet another language.
Source Code:
using namespace std;
int even_odd (int a);
void main ()
            int a, b;
            cout<<”Enter the Number “;
            if (a%2==0 && a>0)
                        cout<<”Even Number \n”;
                        cout<<”Odd Number \n”;
            int even_odd (int a)
                        return a;

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS