File tree 1 file changed +53
-0
lines changed
1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include <stdio.h>
2
+
3
+ int main() {
4
+
5
+ char operator;
6
+
7
+ double first, second;
8
+
9
+ printf("Enter an operator (+, -, *,): ");
10
+
11
+ scanf("%c", &operator);
12
+
13
+ printf("Enter two operands: ");
14
+
15
+ scanf("%lf %lf", &first, &second);
16
+
17
+ switch (operator) {
18
+
19
+ case '+':
20
+
21
+ printf("%.1lf + %.1lf = %.1lf", first, second, first + second);
22
+
23
+ break;
24
+
25
+ case '-':
26
+
27
+ printf("%.1lf - %.1lf = %.1lf", first, second, first - second);
28
+
29
+ break;
30
+
31
+ case '*':
32
+
33
+ printf("%.1lf * %.1lf = %.1lf", first, second, first * second);
34
+
35
+ break;
36
+
37
+ case '/':
38
+
39
+ printf("%.1lf / %.1lf = %.1lf", first, second, first / second);
40
+
41
+ break;
42
+
43
+ // operator doesn't match any case constant
44
+
45
+ default:
46
+
47
+ printf("Error! operator is not correct");
48
+
49
+ }
50
+
51
+ return 0;
52
+
53
+ }
You can’t perform that action at this time.
0 commit comments