Write a C program to enter any number and check whether the given number is even or odd using switch case. How to check even or odd using switch case in C programming. Even or odd program using switch case.

Input number: 12

Output: Even number

Also view this program using -

C program to even or odd number using if else.

C program to check even or odd number using conditional/ternary operator.

C program to check even or odd using functions.

Happy coding ;)

**Example:**Input number: 12

Output: Even number

Also view this program using -

C program to even or odd number using if else.

C program to check even or odd number using conditional/ternary operator.

C program to check even or odd using functions.

### Required knowledge

Basic C programming, Switch case#### Even numbers

Even numbers are the positive integers that are exactly divisible by 2. For example: First 5 even numbers are - 2, 4, 6, 8, 10...#### Odd numbers

Odd numbers are the positive integers that are not exactly divisible by 2. For example: First 5 odd numbers are - 1, 3, 5, 7, 9...### Logic to check even or odd

Logic to this program is simple and straightforward till now we know that for check whether a number is even or odd we need to perform modular division by 2 and if the result of modular division is zero then the number is zero. Means in general if num%2 == 0 then the number is even otherwise odd. If you want to learn how to check divisibility of any number just check this post - C program to check divisibility of any number.### Program to check even or odd

/** * C program to check Even or Odd number using switch case */ #include <stdio.h> int main() { int num; /* * Reads a number from user */ printf("Enter any number to check even or odd: "); scanf("%d", &num); switch(num % 2) { //If n%2 == 0 case 0: printf("Number is Even"); break; //Else if n%2 != 0 case 1: printf("Number is Odd"); break; } return 0; }

Output

Enter any number to check even or odd: 6

Number is Even

Number is Even

Happy coding ;)

### You may also like

- Switch programming exercises index.
- C program to print day of week using switch case.
- C program to create simple Calculator using switch case.
- C program to print sum of all even numbers between 1 to n.
- C program to print sum of all odd numbers between 1 to n.
- C program to check vowel or consonant using switch case.
- C program to find maximum between two numbers using switch case.
- C program to print total number of days in a month using switch case.
- C program to print Fibonacci series up to n terms.
- C program to print all Prime numbers between 1 to n.
- C program to print all Armstrong numbers between 1 to n.
- C program to print all Prime factors of a number.

< code >< pre > -- Your source code -- < /pre >< /code > (Remove spaces from pre and code tags).