Print all even number in c programming

To print all even number from a range in c programming, we have to check all number between given range. To check if the number is odd or even number, we can use this following logic:
The rule is, if any number is fully divided by 2, then this number is even. Else the number is odd. 
Even and Odd

For example

If we want to check whether the number 5 odd or even, we need to simply divide the number by 2.
If there is any reminder left, or if there is any value of 5 mod 2 left, that means 5 is not divisible by 2. So 5 is odd number.

Find modulus:

At first, the question is what is modulus?
Modulus
Modulus is the remainder after division of one number by another number. Modulus is also called remainder. For example if we try to divide 5 by 2, we will have some remainder or modulus.
5/2 = 2 and 1 is remainder. Modulus is define by mod.
We can find this remainder easily in c programming. We also can find quotient easily both calculator and using c programming. But sometimes there is no mod button in our scientific calculator. So question is, how to find modulus by simple calculation.

MARI themes

Powered by Blogger.