code
DO IT YOURSELFprevious code
#include<constream.h>
#include<iomanip.h>
void add(int,int);
void subtraction(int,int);
void mult(int,int);
void div(int ,int);
void main(){
char choice;
do{
clrscr();
cout<<"--------- MENU ---------"<<endl;
cout<<"a : ADDITION"<<endl;
cout<<"m : MULTIPLICATION"<<endl;
cout<<"d : DIVISION"<<endl;
cout<<"s : SUBTRACTION"<<endl;
cout<<"e : EXIT"<<endl;
cout<<"--------- END ---------"<<endl;
cout<<"plzz enter your choice"<<endl;
cin>>choice;
int num1,num2;
switch(choice)
{
case 'a':
cout<<"plzz enter number";
cin>>num1;
cout<<"plzz enter number";
cin>>num2;
add(num1,num2);
break;
case 'm':
cout<<"plzz enter number";
cin>>num1;
cout<<"plzz enter number";
cin>>num2;
mult(num1,num2);
break;
case 'd':
cout<<"plzz enter number";
cin>>num1;
cout<<"plzz enter number";
cin>>num2;
div(num1,num2);
break;
case 's':
cout<<"plzz enter number";
cin>>num1;
cout<<"plzz enter number";
cin>>num2;
subtraction(num1,num2);
break;
}
}while(choice!='e');
getch();
}
void add(int a,int b)
{
cout<<"Result = "<<a+b;
getch();
}
void subtraction(int a,int b)
{
cout<<"Result = "<<a-b;
getch();
}
void mult(int a,int b)
{
cout<<"Result = "<<a*b;
getch();
}
void div(int a,int b)
{
cout<<"Result = "<<a/b;
getch();
}
No comments:
Post a Comment