Check Even Odd with Switch Statement

By | July 23, 2023

Check Even Odd with Switch Statement – C Program to input a number and check it for even or odd using a switch statement.

Check Even Odd Using Switch statement C Program

Check Even Odd Using Switch statement C Program

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
——————————–

Loading

Leave a Reply

Your email address will not be published. Required fields are marked *