# C Program to Check Whether a Number is Odd or Even Number using Switch Case Statement

• Write a C program to check whether it is odd or even number using switch case statement.
• How to check a number is odd or even in C.

Required Knowledge

• C printf and scanf functions
• Switch case statement in C

Any numbers divisible by 2 are even numbers whereas numbers which are not divisible by 2 are odd numbers. Any even number can be represented in form of (2*N) whereas any odd number can be represented as (2*N + 1). Even Numbers examples: 2, 6 , 10, 12 Odd Number examples: 3, 5, 9 ,15

### C program to check a number is Even of Odd using switch case statement #include <stdio.h>
#include <conio.h>

int main() {
int num;

/* Take a number as input from user
using scanf function */
printf("Enter an Integer\n");
scanf("%d", &num);

switch(num%2) {
/* Even numbers completely are divisible by 2  */
case 0: printf("%d is Even", num);
break;
/* Odd numbers are not divisible by 2 */
case 1: printf("%d is Odd", num);
break;
}

getch();
return 0;
}

Output

Enter an Integer
8
8 is Even

Enter an Integer
5
5 is Odd