# C program to check a number even, odd or zero

In this program, we will test a given number by users weather the number is even, odd or zero using C programming. To do this we will use basic component of C syntax. The logic behind this problem is check the number even or odd, so we know to check logic in C programming, we use basic if else expressions.

Output: You entered an odd number!

## Mathematical logic to check Even or Odd

By using our general school mathematical knowledge, how can we determine if a number is even or odd. To do this, simply take a number and divided by 2 then notice of its reminder. If the reminder is 1 then again focus on the taken number, it will be a odd number.

And similarly, if the reminder is 0, then obviously it is an even number. See the simple math above. Now we will implement this problem in C program.

## Simple logic

First we will take a variable say `N`

to store the given value (simple integers `int N`

) by users. Then we will divide it by 2 and check the reminder using the C modulus operator `N%2 == 0`

or `N%2 == 1`

. After then we will check the reminder by using simple `if.. else`

conditions. Finally output it as the sample input output above. Let’s implement it.

To take input value from users, use `scanf`

function and to display the output we will use `printf`

function which is defined in the stdio.h standard function library along with many other basic function and expressions.

If you are very beginner in C programming, then you can start learning our basic C tutorial,

**Start learning C now!**

C Programming Tutorial

## Program to Check Even or Odd Numbers

```
/* C program to check Even or Odd (main.c)*/
#include <stdio.h>
int main() {
int N;
printf("Enter a number: ");
scanf("%d", &N);
if(N==0) {
printf("You entered Zero!\n");
} else if (N%2==0) {
printf("You entered an Even number!\n");
} else {
printf("You entered an Odd number!\n");
}
return 0;
}
```

## Output:

Output: You entered an even number!

____________________

Input: Enter a number: 0

Output: You entered Zero!

____________________

Input: Enter a number: 15

Output: You entered an odd number!

ðŸ™‚ Â Easy Coding

- C program to print Integer & Decimal number given by user
- C Program to perform all arithmetic calculation
- C program to ask two numbers and find their sum
- C program to check a number is even, odd or zero
- C program to swap between two numbers
- C program to sum of natural numbers up to N
- C program to calculate the factorial of a number
- C program to make a multiplication table
- C program to calculate GCD of two numbers
- C program to calculate LCM of two numbers
- C program to count number of digits in a number
- C program to reverse a integer number
- C program to find the power of a number
- C program to check whether a number is palindrome or not
- C program to count and print prime numbers up to the N
- C program to check armstrong numbers
- C program to check armstrong numbers between two integers
- C program to find factors of a number
- C program to fined the size of all data types
- C program to print largest number among three numbers
- C program to check a number is positive or negetive
- C program to calculate the factorial of a number
- C program to form any kind of pyramid and stracture
- C program to find all the prime numbers between two numbers
- C program to check whether a number is prime or not
- C program to make a simple calculator
- C program to calculate the perimeter of a rectangle
- C program to calculate the area of a rectangle
- C program to calculate the diameter and area of a circle
- C program to convert kilometer to meter and centimeter
- C program to convert temperature celsius to fahrenheit
- C program to convert temperature fahrenheit to celsius
- C program to ask for days and convert into years, week and days
- C program to calculate the square root of a given number
- C program to find third angle of a triangle where two angles are given
- C program to calculate the area of a triangle
- C program to calculate area of an equilateral triangle
- C program to calculate average and percentage of result
- C program to calculate simple loan interest
- C program to compound loan interest
- C program to display fibonacci series of a number
- C program to swap two numbers without using third variable
- C program to print Hello World without using semicolon
- C program to insert assembly code and run it
- C program to printf Hello world without main() function
- C program to to calculate the multiplication of two matrix
- C program to convert decimal numbers into binary
- C program to form a triangle made with alphabet
- C program to form a triangle made with numbers
- C program to form a fibonacci triangle
- C program to convert a number into charecters