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
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
Post a Comment