# C Program to Check Odd or Even

How to write a C Program to Check Odd or Even number using If Statement and Conditional Operator with an example of each?. If a number is divisible by 2, it is an even number, and the remaining (not divisible by 2) are odd numbers.

## C Program to Check Odd or Even using IF Condition

This program allows the user to enter an integer. Next, this C program shows how to find even and odd numbers using the If statement.

In C Programming, we have an Arithmetic Operator called % (Module) to check the remainder of the division. Let’s use this operator to find the remainder. If the remainder is 0, then the number is even else odd.

Within this C example, the printf statement will ask the user to Enter a value to check whether it is Even or Odd. The scanf statement will assign the user entered a value to a number variable.

In the Next line, We declared the If statement. Please refer Arithmetic Operator in C Programming. If condition check whether the remainder of the number divided by 2 is exactly equal to 0 or not.

• If the condition is True, it is Even number
• If the condition is False, it is an Odd.
```#include<stdio.h>

int main()
{
int number;

printf(" Enter an int value to check  \n");
scanf("%d", &number);

if ( number%2 == 0 ) //Check whether remainder is 0 or not
printf("Given number %d is EVEN NUMBER \n", number);

else
printf("Given number %d is ODD NUMBER \n", number);

return 0;
}```

Enter the second value to check for the even number

`````` Enter an int value to check Even or Odd
98
Given number 98 is EVEN NUMBER ``````

In the above code, we used if condition to check whether the remainder of the given integer is 0 or not and print as per the result.

## C Program to Check Even or Odd using Conditional Operator

We can also use the Conditional operator to check whether the number 24 is odd or even in c programming. Let’s see the example program of this.

```#include<stdio.h>

int main()
{
int number;

printf(" Enter an int value to check \n ");
scanf("%d",&number);

number%2 == 0 ? printf(" Even \n ") : printf(" Odd \n");

return 0;
}```

output

`````` Enter an int value to check
24
Even``````

Try other value too

`````` Enter an int value to check
19
Odd``````