Skip to content
Home » Even Odd Program in C Using the Switch case

Even Odd Program in C Using the Switch case

Learn about Even Odd Program in C Using the Switch case in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

Even Odd Program in C Using the Switch case

Program:

#include<stdio.h>
int main()
{
  int n, rem;

  printf("Enter Number: ");
  scanf("%d",&n);
  rem = n % 2;

  switch(rem)
  {
  case 0:
   printf("Even\n");
   break;

  case 1:
   printf("Odd\n");
   break;

  default:
   printf("Invalid");
   break;
  }

  return 0;
}

Output:

Enter Number: 6
Even

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Codes :
Even odd program in C using if-else
Odd Number Program in C