Friday, October 8, 2010

circle and cylinder

#include
#include
Class point
{
Protected:
Int xcor;
Int ycor;
Public:
Point(int x,int y)
{
Xcor=x;
Ycor=y;
}
Virtual void area()=0;
Virtual void volume()=0;
};
Class circle:public point
{
Protected:
Float radius;
Float area;
Float volume;
Public:
Void area(float rad)
{
Radius=rad;
Area=3.14*radius*radius;
Cout<}
Void volume(float rad)
{
Radius=rad;
Volume=(4/3)*3.14*radius*radius*radius;
Cout<}
};
Class cylinder:public circle
{
Protected:
Float height;
Float area1;
Float volume1;
Public:
Void area(float hei)
{
Height=hei;
Area1=2(circle::area)+2(3.14*circle::radius*height);
Cout<}
Void volume(float hei)
{
Height=hei;
Volume1=( circle::area)*height;
Cout<}
};
Void main()
{
Point p;
P.point(5,6);
Circle c1,c2;
C1.area(5.5);
C2.area(5.5);
Cylinder c3,c4;
C3.area(4.1);
C4.volume(4.1);
}

No comments:

Post a Comment