You will learn about C++ program to check whether number is even or odd. Integers which are perfectly divisible by 2 are called even numbers and odd if it is not divisible by two.
To check whether an integer is even or odd the remainder is calculated when it is divided by 2 using modulus operator %. If remainder is zero then number is even if not that number is odd.
Some of the even numbers are :
Some of the odd numbers are :
For the better understanding of this program you have to know more about the following C++ programming topic(s) :
C++ Flow Control
To check whether an integer is even or odd the remainder is calculated when it is divided by 2 using modulus operator %. If remainder is zero then number is even if not that number is odd.
Some of the even numbers are :
2, 4, 6, 8,10,12
Some of the odd numbers are :
1, 3, 5, 7, 9, 11
For the better understanding of this program you have to know more about the following C++ programming topic(s) :
C++ Flow Control
The formula is to calculate quotient and remainder is
num % 2 == 0 then number is even
Example#4.0: C++ program to check whether number(integer) is even or odd without function
Output
Enter an integer : 1258
1258 is even integer.
Example#4.1: C++ program to check whether number(integer) is even or odd using function
Output
Enter an integer : 1258
1258 is even integer.
Post a Comment
Thank you for vising