Skip to content

Commit 82385f4

Browse files
committed
switch case statement
1 parent b1f0c54 commit 82385f4

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

Level 2/switch_case.cpp

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
int main()
6+
{
7+
int a, b;
8+
9+
cout << "Enter two numbers : " << endl;
10+
11+
cin >> a >> b;
12+
13+
char op;
14+
15+
cout << "Enter the operation which you want to perform : " << endl;
16+
17+
cin >> op;
18+
19+
switch (op)
20+
{
21+
case '+':
22+
cout << "Addition of two numbers : " << a + b << endl;
23+
break;
24+
case '-':
25+
cout << "Subtraction of two numbers : " << a - b << endl;
26+
break;
27+
case '*':
28+
cout << "Multiplication of two numbers : " << a * b << endl;
29+
break;
30+
case '/':
31+
cout << "Division of two numbers : " << a / b << endl;
32+
break;
33+
default:
34+
cout << "You enter invalid operatio" << endl;
35+
}
36+
37+
return 0;
38+
}

0 commit comments

Comments
 (0)