C++ program to find whether a number is even or odd

#include<iostream>
using namespace std;
int odd_even(int num);
int main()
{
int num,flag;
cout<<"Enter a number to check for odd or even\n ";
cin>>num;
flag=odd_even(num);
if(flag==1)
cout<<"Even";
else
cout<<"odd";

}
int odd_even(int num)
{

if(num%2==0)
return 1;
else
return 0;
}
OUTPUT:
Enter a number to check for odd or even
 3
odd

Comments

Popular posts from this blog

cpanel exam CPSP Answers

How to install zimbra collaboration suite 8.8.11 on CentOS 7

awstats installation