C Program to display arithmetic operator using switch case

/* Switch Case */
#include
#include
void main()
{
int a,b,n,c;
clrscr();
printf("Enter A : ");
scanf("%d",&a);
printf("Enter B : ");
scanf("%d",&b);
printf("\n Select any one case");
printf("\n 1. Addition");
printf("\n 2. Subraction");
printf("\n 3. Multiplication");
printf("\nEnter the Case : ");
scanf("%d",&n);
switch(n)
{
case 1:
c=a+b;
break;
case 2:
c=a-b;
break;
case 3:
c=a*b;
break;
default:
printf("Block terminated");
break;
}
printf("The result is %d",c);
getch();
}

Output
Enter A : 12
Enter B : 23
Select any one case
1. Addition
2. Subraction
3. Multiplication
Enter the Case :1
The result is 35

Comments

Join as a footSigns Travel Writer...

Name

Email *

Message *