Even odd test – CSKC
Sign In

Search

Solved Problem #CPP#2012    siteicon   siteicon  

Problem Statement - Even odd test

Write a c++ program to test if the user given integer value is an even number or an odd number.

Solution

TC++ #2012

 

×

Ask AI About This Code

Default Prompt that is passed along with the code is given below, You can write your own prompt if you so desire.



×

Test CPP

if(n%2==0) cout<<“The number is even”;
If the remainder of number when divided by 2 is 0 then it is an even number. This is called divisibility test, which is done by using the % (Mod) operator.

else cout<<“The number is odd”;
This is printed when the if condition is not true. So if the divisibility by 2 is not true then it is an odd number.


Share

Created: 29-Dec-2017 14:09 | Updated: 13-Dec-2018 23:42|