using namespace std;
#define add(a,b) a+b
#define subtract(a,b) a-b
#define multiply(a,b) a*b
#define divide(a,b) a/b
#define circle(r) 3.142*r*r
#define rectangle(length,breath) length*breath
#define square(side) side*side
#define compare(a,b) (a==b?"nnumbers are equal":(a>b?" a is greater ":"b is greater ")
int main(){
int a,b,r,length,breath,side,choice;
while(true){ //while(true) loop is used to run program indefinitely.
cout<<"enter 1 to add"<<endl;
cout<<"enter 2 to subtract"<<endl;
cout<<"enter 3 to multiply"<<endl;
cout<<"enter 4 to divide"<<endl;
cout<<"enter 5 to circle"<<endl;
cout<<"enter 6 to rectangle"<<endl;
cout<<"enter 7 to square"<<endl;
cout<<"enter 8 to compare valuses "<<endl;
cin>>choice;
switch(choice)
{
case 1:
cout<<"enter 1st and 2nd values"<<endl;
cout<<" 1st value = ";
cin>>a;
cout<<" 2nd value = ";
cin>>b;
cout<<"the result of addition = "<<add(a,b)<<endl;
break;
case 2:
cout<<"enter 1 and 2 values"<<endl;
cout<<" 1st = ";
cin>>a;
cout<<" 2nd = ";
cin>>b;
cout<<"the result of subtraction = "<<subtract(a,b)<<endl;
break;
case 3:
cout<<"enter 1 and 2 values"<<endl;
cout<<" 1st = ";
cin>>a;
cout<<" 2nd = ";
cin>>b;
cout<<"the result of multiplication = "<<multiply(a,b)<<endl;
break;
case 4:
cout<<"enter 1 and 2 values"<<endl;
cout<<" 1st =";
cin>>a;
cout<<" 2nd = ";
cin>>b;
cout<<"the result of division = "<<divide(a,b)<<endl;
break;
case 5:
cout<<"enter radius"<<endl;
cout<<"the radius of circle =";
cin>>r;
cout<<endl;
cout<<"the area of circle = "<<circle(r)<<endl;
break;
case 6:
cout<<"enter length and breath"<<endl;
cout<<" length = ";
cin>>length;
cout<<" breath ";
cin>>breath;
cout<<"the area of rectangle = "<<rectangle(length,breath)<<endl;
break;
case 7:
cout<<"enter 1 side of square"<<endl;
cout<<" side of square = ";
cin>>side;
cout<<"the area of square = "<<square(side)<<endl;
break;
case 8:
cout<<"enter 1 and 2 values"<<endl;
cout<<" 1st = ";
cin>>a;
cout<<" 2nd = ";
cin>>b;
cout<<compare(a,b))<<endl;
break;
}
}
}
EmoticonEmoticon