Write a Program to perform even odd or sum using switch case

/*
    Program to perform even odd or sum
*/
#include<stdio.h>
#include<conio.h>
void main()
{
int num1,num2,choice;

printf("\n\nMenu");
printf("\n\n1.To find wether the given Number is Even or Odd");
printf("\n\n2.To find the sum of given two numbers");

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


switch(choice)
{
case 1: printf("\n\nEnter any number: ");
scanf("%d",&num1);
        if(num1%2==0)
{
printf("The Entered number is even");
}
else
{
printf("The Entered number is odd");
}
break;
case 2: printf("\n\nEnter any 2 numbers: ");
        scanf("%d%d",&num1,&num2);
       
        printf("\n\nSum=%d",num1+num2);
        break;
default: printf("\n\nWrong Choice");
       
}
getch();

}

Previous
Next Post »