c program to print calculator using switch statement

Solutions on MaxInterview for c program to print calculator using switch statement by the best coders in the world

showing results for - "c program to print calculator using switch statement"
Valerio
12 Nov 2016
1#include<stdio.h> 
2int main()
3{ 
4int a, b, total;
5char op; 
6printf("Enter the number");
7scanf("%d%c%d", &a, &op, &b);
8switch(op)
9{
10case '+':
11total = a + b;
12break;
13case '-':
14total = a - b;
15break;
16case '*':
17total = a * b;
18break;
19case '/':
20total = a / b;
21break; 
22}
23printf("total = %d", total);
24return 0; 
25}