# Program to make a simple calculator to add, subtract, multiply or divide using switch case in C

## Source Code

```// 29. Program to make a simple calculator to add, subtract, multiply or divide using switch case
// Arpan Das - CST 2nd Year (VOCLET)

#include <stdio.h>

void main () {
int ch;
float x, y;
//clrscr();

printf("\t\t..:: simple calculator to add, subtract, multiply or divide using switch case ::..\n\n");

do {
printf("\n1. Addition\n2. Subtraction\n3. Multiplication\n4. Division\n5. Exit\n");
scanf("%d", &ch);

switch (ch) {
case 1:
printf("\nEnter operand1 and operand2 respectively: ");
scanf("%f%f", &x, &y);
printf("\n\tResult: %.3f\n", x+y);
break;
case 2:
printf("\nEnter operand1 and operand2 respectively: ");
scanf("%f%f", &x, &y);
printf("\n\tResult: %.3f\n", x-y);
break;
case 3:
printf("\nEnter operand1 and operand2 respectively: ");
scanf("%f%f", &x, &y);
printf("\n\tResult: %.3f\n", x*y);
break;
case 4:
printf("\nEnter operand1 and operand2 respectively: ");
scanf("%f%f", &x, &y);
printf("\n\tResult: %.3f\n", x/y);
break;
default:
break;
}
} while (ch >= 1 && ch <= 4);
}```

## Output

``````		..:: simple calculator to add, subtract, multiply or divide using switch case ::..

2. Subtraction
3. Multiplication
4. Division
5. Exit

Enter operand1 and operand2 respectively: 12 14

Result: 26.000

2. Subtraction
3. Multiplication
4. Division
5. Exit

Enter operand1 and operand2 respectively: 20 5

Result: 15.000

2. Subtraction
3. Multiplication
4. Division
5. Exit

Enter operand1 and operand2 respectively: 5 6

Result: 30.000

2. Subtraction
3. Multiplication
4. Division
5. Exit