Practical-19
#include<iostream>
#include<math.h>
using namespace std;
class circle
{
protected:
int radius;
int height;
public:
void getdata();
};
void circle::getdata()
{
cout<<"Enter radius";
cin>>radius;
cout<<"Enter height";
cin>>height;
}
class cylinder:public circle
{
float volume;
float area;
public:
void volume1();
void display();
};
void cylinder::volume1()
{
cout<<radius<<height;
area=radius*radius;
volume=(M_PI*(area)*height);
}
void cylinder :: display()
{
cout<<"area="<<area<<"\n";
cout<<"Volume="<<volume<<"\n";
}
int main()
{
cylinder c2;
c2.getdata();
c2.volume1();
c2.display();
return 0;
}
No comments:
Post a Comment