Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void sum(int x , int y)
- {
- cout<<"The result = "<<x+y;
- }
- void sub(int x , int y)
- {
- cout<<"The result = "<<x-y;
- }
- void multi(int x , int y)
- {
- cout<<"The result = "<<x*y;
- }
- void divi(int x , int y)
- {
- cout<<"The result = "<<x/y;
- }
- int main()
- {
- int x,y;
- char op;
- cout<<"Enter the first number"<<endl;
- cin>>x;
- cout<<"Enter the second number"<<endl;
- cin>>y;
- cout<<"Enter the operator + - * /"<<endl;
- cin>>op;
- switch(op)
- {
- case '+':
- sum(x,y);
- break;
- case '-':
- sub(x,y);
- break;
- case '*':
- multi(x,y);
- break;
- case '/':
- divi(x,y);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment