File tree Expand file tree Collapse file tree 2 files changed +84
-0
lines changed Expand file tree Collapse file tree 2 files changed +84
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+
3
+ void add (int x , int y) {
4
+
5
+ std::cout << x + y << std::endl;
6
+ }
7
+
8
+ void sub (int x, int y) {
9
+
10
+ std::cout << x - y << std::endl;
11
+ }
12
+
13
+ void mul (int x, int y) {
14
+
15
+ std::cout << x * y << std::endl;
16
+ }
17
+ int main () {
18
+
19
+ std::cout << " 1.Add" << std::endl;
20
+ std::cout << " 2.Sub" << std::endl;
21
+ std::cout << " 3.Mul" << std::endl;
22
+
23
+ int choice;
24
+ std::cout << " Enter Yiur Choice : " << std::endl;
25
+ std::cin >> choice;
26
+
27
+ switch (choice) {
28
+
29
+ case 1 :
30
+ add (10 , 20 );
31
+ break ;
32
+ case 2 :
33
+ sub (30 , 20 );
34
+ break ;
35
+
36
+ case 3 :
37
+ mul (10 , 20 );
38
+ break ;
39
+ }
40
+ return 0 ;
41
+ }
Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+
3
+ void add (int x , int y) {
4
+
5
+ std::cout << x + y << std::endl;
6
+ }
7
+
8
+ void sub (int x, int y) {
9
+
10
+ std::cout << x - y << std::endl;
11
+ }
12
+
13
+ void mul (int x, int y) {
14
+
15
+ std::cout << x * y << std::endl;
16
+ }
17
+ int main () {
18
+
19
+ std::cout << " 1.Add" << std::endl;
20
+ std::cout << " 2.Sub" << std::endl;
21
+ std::cout << " 3.Mul" << std::endl;
22
+
23
+ int choice;
24
+ std::cout << " Enter Yiur Choice : " << std::endl;
25
+ std::cin >> choice;
26
+
27
+ void (*fun)(int , int ) = NULL ;
28
+ switch (choice) {
29
+
30
+ case 1 :
31
+ fun = add;
32
+ break ;
33
+ case 2 :
34
+ fun = sub;
35
+ break ;
36
+
37
+ case 3 :
38
+ fun = mul;
39
+ break ;
40
+ }
41
+ fun (30 , 40 );
42
+ return 0 ;
43
+ }
You can’t perform that action at this time.
0 commit comments