Write a c program to check the number is even or odd using switch case

Even or Odd Using Switch Case

In this program, you will learn how to check the number is even or odd in c using switch case(input enter by the user). 

Check the number is even or odd using switch case:


#include<stdio.h>

#include<conio.h>
main()
{
int x,y;
printf("Enter the value to check even or odd:\n");
scanf("%d",&x);
y=x%2==0?1:0;
switch(y)
{
case 1:
printf("Number is Even");
break;
case 0:
printf("Number is Odd");
break;
default:
printf("thank you");
}
getch();
}


Output:



Post a Comment

0 Comments