Get the FREE certificate on C, C++, Java, Python, Perl, PHP, SQL, Linux & Javascript!  

CppBuzz.com
  
Home C C++ Java Python Perl PHP Spring SQL Javascript Linux

You are here : Home » Solved Programs on C++ » C++ program to check if sequence of nos

C++ program to check if sequence of nos are even or odd

#include<iostream>
using namespace std;

int even(int no)
{
if(no%2 == 0)
return 1;
else
return 0;
}

int main()
{
int no;
int result = 0;
cout<<"\n Enter any no: ";
cin>>no;

result = even(no);

if(result == 1)
cout<<"\n No is even";
else
cout<<"\n No is odd";


cout<<"\n Enter any no: ";
cin>>no;

result = even(no);

if(result == 1)
cout<<"\n No is even";
else
cout<<"\n No is odd";


cout<<"\n Enter any no: ";
cin>>no;

result = even(no);

if(result == 1)
cout<<"\n No is even";
else
cout<<"\n No is odd";


cout<<"\n Enter any no: ";
cin>>no;

result = even(no);

if(result == 1)
cout<<"\n No is even";
else
cout<<"\n No is odd";

return 0;
}