Assignments » Flow Of Control » Set1 » Solution 1

Any integer is input by the user. Write a program to find out whether it is an odd number or even number.

 

#include<iostream>
using namespace std;


int main()
{
	int a;
	cout<<"Enter any number : ";
	cin>>a;

	if(a%2==0)
		cout<<"The number is even";
	else
		cout<<"The number is odd";
	

	return 0;
}

 

 

SAMPLE RUN # 1

Enter any number : 68
The number is even

SAMPLE RUN # 2

Enter any number : 43
The number is odd