//create a calculator using switch-case
#include<stdio.h>
int main()
{
double a,b;
char c;
printf("Enter operation= ");
scanf("%c",&c);
printf("\nEnter a=");
scanf("%lf",&a);
printf("\nEnter b=");
scanf("%lf",&b);
switch(c)
{
case '+':
printf("\nsum=%lf",a+b);
break;
case '-':
printf("\nsub=%lf",a-b);
break;
case '*':
printf("\nmul=%lf",a*b);
break;
case '/':
printf("\ndiv=%lf",a/b);
break;
default:
printf("\nInvalid operation");
}
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: