File tree Expand file tree Collapse file tree 1 file changed +58
-0
lines changed
Expand file tree Collapse file tree 1 file changed +58
-0
lines changed Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6+ < title > Document</ title >
7+ </ head >
8+ < body >
9+
10+ < h1 > Welcome to the Calculator App</ h1 >
11+ \begin{pre}
12+ #include < iostream >
13+ using namespace std;
14+
15+ int main() {
16+ double num1, num2, result;
17+ char operation;
18+
19+ cout < < "Enter first number: ";
20+ cin > > num1;
21+
22+ cout < < "Enter operator (+, -, *, /): ";
23+ cin > > operation;
24+
25+ cout < < "Enter second number: ";
26+ cin > > num2;
27+
28+ switch(operation) {
29+ case '+':
30+ result = num1 + num2;
31+ break;
32+ case '-':
33+ result = num1 - num2;
34+ break;
35+ case '*':
36+ result = num1 * num2;
37+ break;
38+ case '/':
39+ if(num2 != 0) {
40+ result = num1 / num2;
41+ } else {
42+ cout < < "Error: Division by zero" < < endl;
43+ return 0;
44+ }
45+ break;
46+ default:
47+ cout < < "Error: Invalid operator" < < endl;
48+ return 0;
49+ }
50+
51+ cout < < "Result: " < < result < < endl
52+
53+ return 0;
54+ }
55+ \end{pre}
56+
57+ </ body>
58+ </ html>
You can’t perform that action at this time.
0 commit comments