Program to display arithmetic operator using switch case

Write a Program to display arithmetic operator(addition,subtrtaction,multiplication,division using switch case:-

#include<stdio.h>

void main()
{
int a,b,n,sum,multiply,sub,div;

printf("Enter two Number`s : \n");
scanf("%d%d",&a,&b);

printf("enter 1 for sum\n 2 for multiply\n 3 for subtraction\n 4 for division:\n ");
scanf("%d",&n);

switch(n)
{
case 1:
sum=a+b;
printf("sum is=%d",sum);
break;
case 2:
multiply=a*b;
printf("multiplication is=%d",multiply);
break;
case 3:
sub=a-b;
printf("subtraction is=%d",sub);
break;
case 4:
div=a/b;
printf("division is=%d",div);
break;
default:
printf("wrong input Entered");
break;
}
}

Related Posts