-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculator.cpp
More file actions
48 lines (46 loc) · 867 Bytes
/
calculator.cpp
File metadata and controls
48 lines (46 loc) · 867 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
36
37
38
39
40
41
42
43
44
45
46
47
48
#include<iostream>
using namespace std;
int add(int x,int y)
{
return (x+y);
}
int substract(int x,int y)
{
return(x-y);
}
int multiply(int x,int y)
{
return(x*y);
}
int divide(int x, int y)
{
return(x/y);
}
int main()
{
cout<<"enter your choice from 1 to 4"<<endl<<"1-addition"<<endl<<"2-substraction"<<endl<<"3-multiply"<<endl<<"4-divide"<<endl;
int no,first,second;
cin>>no;
cout<<"enter first no on which operation to be performed"<<endl;
cin>>first;
cout<<"enter second no "<<endl;
cin>>second;
cout<<"Result is :";
switch (no) {
case 1:
cout<<add(first,second);
break;
case 2:
cout<<substract(first,second);
break;
case 3:
cout<<multiply(first,second);
break;
case 4:
cout<<divide(first,second);
break;
default:
cout<<"choose wrong choice";
}
return 0;
}