# Check Even or Odd number program in C

## Program Description:

Write a C Program to check if the given number is an Even number or Odd number ( an Even odd program ).

Input:

Output:

Input:

Output:

## Even or Odd Number Program Logic:

Any Number that can be divided exactly by 2 is an Even number. Even numbers give zero as the remainder when divided by 2.

Even Number Examples: 2, 4, 50, 100, etc.

Similarly, any number which is not exactly divided by 2 is called Odd number. Odd numbers give 1 as the remainder when divided by 2.

Odd Number Examples: 5, 31, 59, 99, etc.

We are going to use the above logic that Even numbers give us the zero remainder and Odd number gives one (1) as remainder when divided by 2.

We can get the remainder of any integer using the Modulus operator (%).

If the Modulus of input number is zero, Then the Input number is Even number.

If the Modulus of input number is One(1), Then the Input number is Odd number.

Let’s convert above logic into the code.

## Program Output:

We are using gcc compiler in Linux OS.

As you can see from above output, We are getting the expected output. Please play around with program by providing the different inputs.

Let’s write another program to display all Even numbers and Odd numbers from 0 to 100 using loops in C language.

## Example 1: Program to display all Even Numbers and Odd numbers from 0 to 100.

We are going to use the same logic as above. i.e To use the modulus operator to calculate the remainder. But instead of checking for one value, We are going to print all even and odd numbers between 0 and 100.

We are going to use the for loop to iterate over numbers.

## Related Math Programs: 