Friday, 8 February 2013

How to Find Even Odd Number using Function

Question: 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:
#include <iostream>
using namespace std;
int even_odd (int a);
void main ()
{
            int a, b;
            cout<<"Enter the Number ";
            cin>>a;
            if (a%2==0 && a>0)
                        cout<<"Even Number \n";
            else
                        cout<<"Odd Number \n";
}

            int even_odd (int a)
            {
                        return a;
            }

Output: 

programmers,


c programming


 
Tag: what is a odd number, which numbers are odd, what are odd number, what odd numbers, what are the odd number, integer random, odd number is, programming in c, dev c download, programming with c, in c programming, programmers, microsoft visual c, c compilers, even, odd number, program



Subscribe to get the latest right to your inbox:

0 comments:

Post a Comment

Some HTML Code