C Program to Check if Given Number is Odd or Even using Switch Case

C Program to Check if Given Number is Odd or Even using Switch Case

Write C Program to Check if the Given Number is Odd or Even using Switch Case

//WAP to check the given number is odd or even using the switch case

#include <stdio.h>

int main()
{
	int n;

	printf("Enter the number :--> ");
	scanf("%d", &n);

	int x = n % 2;

	switch(x)
    {
        case 0:
            printf("Number is Even");
            break;

        case 1:
            printf("Number is Odd");
            break;
    }

	return 0;
}

Output:

Run 1:
Enter the number :--> 56
Number is Even

Run 2:
Enter the number :--> 57
Number is Odd