In this example, We will check whether number is even or odd.
To check whether number is even or odd, We will divide number by 2. If it gives remender 0 then that number is even otherwise that number is odd.
Let’s look an example to make clear concepts
using namespace std;
cout << "Enter a Number: ";
cin >> num;
if( num % 2 == 0 )
cout<<"\nIt is an Even Number." << endl;
cout<<"\nIt is an Odd Number." << endl;
The output of above program is
Enter a Number : 10
It is an Even Number
Enter a Number : 11
It is an Odd Number
Get the latest tutorials, examples and projects updates.
Ads Blocker Detected!!!
We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.
Disable Ad Block
Want Same System