even odd program in c

In this post, we will see about even odd program in c.
Even numbers are those numbers which are divisible by 2 and numbers which are not divisible by 2 are called odd numbers.
There are many ways to check if number is even or odd in C.


Using modulus operator

Output:

Enter an number: 19
19 is an odd number

Using bitwise operator

You can also use bitwise operator to find if number is even or odd. If number is odd, then its least significant digit will always be 1 and when you perform number&1, it will always result in 1.

Output:

Enter an number: 28
28 is an even number

Using conditional operator

You can also use conditional operator to find if number is even or odd.

Output:

Enter an number: 49
49 is an odd number

Without using modulus and bitwise operator

If you are not allowed to use modulus and bitwise operator, you can use below method to find even and odd number in c.

Output:

Enter an number: 52
52 is an even number

That’s all about even odd program in c.

Leave a Reply

Your email address will not be published. Required fields are marked *