-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple_calculator.c
More file actions
35 lines (31 loc) · 865 Bytes
/
simple_calculator.c
File metadata and controls
35 lines (31 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include<stdio.h>
#include<conio.h>
int main(){
int num1, num2;
char op;
printf("Enter the number 1 and number 2 :");
scanf("%d %d", &num1, &num2);
printf("Select the operator '+', '-', '/', '*' : ");
scanf(" %c", &op);
switch(op){
case '+':
printf("The sum is : %d", num1 + num2);
break;
case '-':
printf("The difference is : %d", num1 - num2);
break;
case '*':
printf("The product is : %d", num1 * num2);
break;
case '/':
if(num2 != 0){
printf("The quotient is : %d", num1 / num2);
} else {
printf("Error: Division by zero");
}
break;
default:
printf("Invalid operator");
}
return 0;
}