write a menu driven program using class to perform all arithmetic operations(+,-,*,/) using inline functions
#include<iostream.h>
#include<conio.h>
class arithop
{
public:
int add(int a,int b)
{
return a+b;
}
int sub(int a,int b)
{
return a-b;
}
int mul(int a,int b)
{
return a*b;
}
float div (int a,int b)
{
return float(a/b);
}
} ;
void main()
{ arithop a;
char op;
int num1,num2,a1,a2,a3;
float a4;
clrscr();
cout<<"enter the operation";
cin>>op;
cout<<"enter two numbers";
cin>>num1>>num2;
switch(op)
{
case '+':a1=a.add(num1,num2);
cout<<"The Addition is"<<a1;
break;
case '-':a2=a.sub(num1,num2);
cout<<"The subtraction is"<<a2;
break;
case '*':a3=a.mul(num1,num2);
cout<<"The multiplication is"<<a3;
break;
case '/':a4=a.div(num1,num2);
cout<<"The division is"<<a4;
break;
default: cout<<"This is a wrong opearation performed";
}
getch();
}
#include<conio.h>
class arithop
{
public:
int add(int a,int b)
{
return a+b;
}
int sub(int a,int b)
{
return a-b;
}
int mul(int a,int b)
{
return a*b;
}
float div (int a,int b)
{
return float(a/b);
}
} ;
void main()
{ arithop a;
char op;
int num1,num2,a1,a2,a3;
float a4;
clrscr();
cout<<"enter the operation";
cin>>op;
cout<<"enter two numbers";
cin>>num1>>num2;
switch(op)
{
case '+':a1=a.add(num1,num2);
cout<<"The Addition is"<<a1;
break;
case '-':a2=a.sub(num1,num2);
cout<<"The subtraction is"<<a2;
break;
case '*':a3=a.mul(num1,num2);
cout<<"The multiplication is"<<a3;
break;
case '/':a4=a.div(num1,num2);
cout<<"The division is"<<a4;
break;
default: cout<<"This is a wrong opearation performed";
}
getch();
}