/*write a menu driven c++ program using class to calculate area and
volume of ractangle using inline function*/
#include<conio.h>
#include<iostream.h>
#include<stdlib.h>
class calculate
{
public:void area(int l,int b);
void volume(int l,int b,int h);
};
inline void calculate::area(int l,int b)
{
int ans;
ans=l*b;
cout<<"\narea of ractangle:-"<<ans;
}
inline void calculate::volume(int l,int b,int h)
{
int ans;
ans=l*b*h;
cout<<"\nvolume of ractangle:-"<<ans;
}
int main()
{
calculate c;
int ch,l,b,h;
clrscr();
while(1)
{
cout<<"\n1:area of ractangle";
cout<<"\n2:volume of ractangle";
cout<<"\n3:exit";
cout<<"\nenter your choice:-";
cin>>ch;
switch(ch)
{
case 1:cout<<"enter the value for length and breath:-";
cin>>l>>b;
c.area(l,b);
break;
case 2:cout<<"\nenter value for length,breath and height:-";
cin>>l>>b>>h;
c.volume(l,b,h);
break;
case 3:exit(0);
default:cout<<"\nyou entered wrong choice";
}
}
getch();
return 0;
}
/*
1:area of ractangle
2:volume of ractangle
3:exit
enter your choice:-1
enter the value for length and breath:-2
3
area of ractangle:-6
1:area of ractangle
2:volume of ractangle
3:exit
enter your choice:-2
enter value for length,breath and height:-1
4
5
volume of ractangle:-20
1:area of ractangle
2:volume of ractangle
3:exit
enter your choice:-3
*/
volume of ractangle using inline function*/
#include<conio.h>
#include<iostream.h>
#include<stdlib.h>
class calculate
{
public:void area(int l,int b);
void volume(int l,int b,int h);
};
inline void calculate::area(int l,int b)
{
int ans;
ans=l*b;
cout<<"\narea of ractangle:-"<<ans;
}
inline void calculate::volume(int l,int b,int h)
{
int ans;
ans=l*b*h;
cout<<"\nvolume of ractangle:-"<<ans;
}
int main()
{
calculate c;
int ch,l,b,h;
clrscr();
while(1)
{
cout<<"\n1:area of ractangle";
cout<<"\n2:volume of ractangle";
cout<<"\n3:exit";
cout<<"\nenter your choice:-";
cin>>ch;
switch(ch)
{
case 1:cout<<"enter the value for length and breath:-";
cin>>l>>b;
c.area(l,b);
break;
case 2:cout<<"\nenter value for length,breath and height:-";
cin>>l>>b>>h;
c.volume(l,b,h);
break;
case 3:exit(0);
default:cout<<"\nyou entered wrong choice";
}
}
getch();
return 0;
}
/*
1:area of ractangle
2:volume of ractangle
3:exit
enter your choice:-1
enter the value for length and breath:-2
3
area of ractangle:-6
1:area of ractangle
2:volume of ractangle
3:exit
enter your choice:-2
enter value for length,breath and height:-1
4
5
volume of ractangle:-20
1:area of ractangle
2:volume of ractangle
3:exit
enter your choice:-3
*/
No comments:
Post a Comment