Check Even Odd with Switch Statement – C Program to input a number and check it for even or odd using a switch statement.
Source Code
#include <stdio.h> int main() { int n; printf("Enter a number to check for Even/Odd:"); scanf("%d",&n); switch(n%2) { case 0: printf("%d is Even",n); break; case 1: printf("%d is Odd",n); break; } return 0; }
Output
Enter a number to check for Even/Odd:10
10 is Even
——————————–
Enter a number to check for Even/Odd:33
33 is Odd
——————————–