Code:
#include<iostream.h>
#include<conio.h>
class figure
{
public:
virtual void Area();
};
class square:public A
{
public:
void Area()
{
int side,x;
cout<<"\nEnter the SIDE of the square\t";
cin>>side;
x=side*side;
cout<<"\nThe AREA of the SQUARE is\t"<<x;
}
};
class Rectangle:public figure
{
public:
void Area()
{
int l,b,y;
cout<<"\nEnter the LENGTH of the rectangle\t";
cin>>l;
cout<<"\nEnter the BREADTH of the rectangle\t";
cin>>b;
y=l*b;
cout<<"\nThe AREA of the rectangle is\t"<<y;
}
};
class Traingle:public figure
{
public:
void Area()
{
int b1,h,z;
cout<<"\nEnter the BREADTH of the traingle\t";
cin>>b1;
cout<<"\nEnter the HIEHGHT of the traingle\t";
cin>>h;
z=0.5*b1*h;
cout<<"\nThe AREA of the traingle is\t"<<z;
}
};
void main()
{
clrscr();
figure f;
square s;
Traingle t;
Rectangle r;
f.void Area();
s.void Area();
t.void Area();
r.void Area();
getch();
}
Comment