Building A Better Calculator
Lesson 19Author : 🦒
Last Updated : November, 2017
Code
int num1, num2;
char op;
printf(("Enter num1: ");
scanf("%d", &num1);
printf(("Enter Operator: ");
scanf("%c", &op);
printf(("Enter num2: ");
scanf("%d", &num2);
if(op == '+'){
printf("%d", num1 + num2);
} else if(op == '-'){
printf("%d", num1 - num2);
} else if(op == '/'){
printf("%d", num1 / num2);
} else if(op == '*'){
printf("%d", num1 * num2);
} else {
printf("Invalid Operator");
}