wap menu driven using class to cal area and volume of rectangle using inline function
#include<iostream.h>
#include<conio.h>
class calc
{
int l,b,h;
public:
inline int area(int l,int b)
{
return l*b;
}
inline float vol(float l1,float b1,float h1)
{
return l1*b1*h1;
}
};
void main()
{
calc c;
char ch;
int n1,n2,c1;
float n3,n4,n5,c2;
clrscr();
cout<<"\n 1.area";
cout<<"\n 2.volume";
cout<<"\n enter the opeartion";
cin>>ch;
switch(ch)
{
case '1':
cout<<"\n enter the 2 numbers";
cin>>n1>>n2;
c1=c.area(n1,n2);
cout<<"area is "<<c1;
break;
case '2':
cout<<"\n enter 3 numbers";
cin>>n5>>n4>>n3;
c2=c.vol(n4,n5,n3);
cout<<"\n volume is "<<c2;
break;
default:cout<<"this program cannot run";
}
getch();
}
#include<iostream.h>
#include<conio.h>
class calc
{
int l,b,h;
public:
inline int area(int l,int b)
{
return l*b;
}
inline float vol(float l1,float b1,float h1)
{
return l1*b1*h1;
}
};
void main()
{
calc c;
char ch;
int n1,n2,c1;
float n3,n4,n5,c2;
clrscr();
cout<<"\n 1.area";
cout<<"\n 2.volume";
cout<<"\n enter the opeartion";
cin>>ch;
switch(ch)
{
case '1':
cout<<"\n enter the 2 numbers";
cin>>n1>>n2;
c1=c.area(n1,n2);
cout<<"area is "<<c1;
break;
case '2':
cout<<"\n enter 3 numbers";
cin>>n5>>n4>>n3;
c2=c.vol(n4,n5,n3);
cout<<"\n volume is "<<c2;
break;
default:cout<<"this program cannot run";
}
getch();
}