Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- void op_fun(int c)
- {
- int x,y;
- switch(c)
- {
- //if the user choose 1
- case 1:
- cout<<"\n-----------------------------------------------\n";
- cout<<"Addition";
- cout<<"\n-----------------------------------------------\n";
- cout<<"Enter First Number : "; cin>>x;
- cout<<"Enter Second Number : "; cin>>y;
- cout<<"The Resualt is : "<<x+y<<endl;
- cout<<"\n-----------------------------------------------\n";
- break;
- //if the user choose 2
- case 2:
- cout<<"\n-----------------------------------------------\n";
- cout<<"Subtraction";
- cout<<"\n-----------------------------------------------\n";
- cout<<"Enter First Number : "; cin>>x;
- cout<<"Enter Second Number : "; cin>>y;
- cout<<"The Resualt is : "<<x-y<<endl;
- cout<<"\n-----------------------------------------------\n";
- break;
- //if the user choose 3
- case 3:
- cout<<"\n-----------------------------------------------\n";
- cout<<"Multiple";
- cout<<"\n-----------------------------------------------\n";
- cout<<"Enter First Number : "; cin>>x;
- cout<<"Enter Second Number : "; cin>>y;
- cout<<"The Resualt is : "<<x*y<<endl;
- cout<<"\n-----------------------------------------------\n";
- break;
- default:
- cout<<"End of programm ";
- }
- }
- int main()
- {
- int c;
- //we uses do while for looping this
- do
- {
- cout<<"1 :Addition \t 2 :Subtraction \t 3 :Multiple \t 4 :Exit \n";
- cout<<"Choose : ";
- cin>>c;
- op_fun(c);
- }while(c!=4);
- }
Advertisement
Add Comment
Please, Sign In to add comment