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

In this C program, we will learn how to check whether it is odd or even number using switch case statement. 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

Required Knowledge


C program to check a number is Even of Odd using switch case statement

#include <stdio.h>  
  
int main() {  
    int num;  
  
    printf("Enter an Integer\n");  
    scanf("%d", &num);  
  
    switch(num%2) {     
        /* Even numbers 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;  
    }  
    
    return 0;  
}
Output
Enter an Integer
8
8 is Even
Enter an Integer
5
5 is Odd

Related Topics
C program to check whether a character is vowel or consonant using switch statement
C program to find sum of least and most significant digits of a number
C program to print name of days in week using switch statement
C program to check a number is odd or even using conditional operator
C program to check odd or even numbers
C program to print natural numbers in reverse order from N to 1
C program to find sum of prime numbers between 1 to N
C program to find twos complement of a binary number
C program to check whether a number is prime or not
List of all C programs