Need a project done?

C++ Programming Developer

Search This Blog

Function to test whether a given integer is Even or Odd


/*
Write  a program by defining a function "even_odd" to test whether a given integer is even or odd.
Pass the integer value as a argument to function.
*/

#include <iostream>
using namespace std;

void even_odd(int);

int main()
{
int Num;
cout<< "Number: "; cin>>Num;
even_odd(Num);

return 0;
}

void even_odd(int Num)
{
if ( 0 == Num%2 ) //or u can write if(Num%2 == 0).
cout<<Num<<" is Even" << endl;
else
cout<<Num<<" is Odd"  << endl;
}
"Don't let anyone ever make you feel like you don't deserve what you want."