Write a Program to check positive , negative , even or odd using switch case

//this is a program to use switch case
#include<stdio.h>
#include<conio.h>
void main()
{
int num, choice;

printf("\n\nMenu");
printf("\n\n1.To Find wether the entered number is positive or negative");
printf("\n\n2.To Find wether the enered number is even or odd");

printf("\n\nEnter Your Choice(1/2): ");
scanf("%d",&choice);

printf("\n\nEnter Any Number: ");
scanf("%d",&num);

switch(choice)
{
case 1: if(num>0)
{
printf("\n\nThe entered number is Positive");
}
else
{
printf("\n\nThe entered number is Negative");
}
break;
case 2: if(num%2==0)
{
printf("The Entered number is even");
}
else
{
printf("The Entered number is odd");
}
break;
default: printf("\n\nWrong Choice");
}
getch();
}

Previous
Next Post »