#include <iostream.h>
#include <conio.h>
class Triangle
{
float b,h;
Triangle()
{
b=0;
h=0;
}
Triangle(float x, float y)
{
b=x;
h=y;
}
float Area()
{
return 0.5*b*h;
}
}
class Circle
{
float r;
Circle()
{
r=0;
}
Circle(float x)
{
r=x;
}
float Area()
{
return 4.3*r*r;
}
}
class Square
{
float a;
Square()
{
a=0;
}
Square(float x)
{
a=x;
}
float Area()
{
return a*a;
}
}
class Rect
{
float l,b;
Rect()
{
l=0;
b=0;
}
Rect(float x, float y)
{
l=x;
b=y;
}
float Area()
{
return l*b;
}
}
void main()
{
clrscr();
Triangle t1(2,4);
cout << "Area of triangle is " << t1.Area();
Circle c(4);
cout << "Area of circle is " << c.Area();
Square s(5);
cout << "Area of Square is " << s.Area();
Rect r(3,6)
cout << "Area of Rectangle is" << r.Area();
getch();
}
#include <conio.h>
class Triangle
{
float b,h;
Triangle()
{
b=0;
h=0;
}
Triangle(float x, float y)
{
b=x;
h=y;
}
float Area()
{
return 0.5*b*h;
}
}
class Circle
{
float r;
Circle()
{
r=0;
}
Circle(float x)
{
r=x;
}
float Area()
{
return 4.3*r*r;
}
}
class Square
{
float a;
Square()
{
a=0;
}
Square(float x)
{
a=x;
}
float Area()
{
return a*a;
}
}
class Rect
{
float l,b;
Rect()
{
l=0;
b=0;
}
Rect(float x, float y)
{
l=x;
b=y;
}
float Area()
{
return l*b;
}
}
void main()
{
clrscr();
Triangle t1(2,4);
cout << "Area of triangle is " << t1.Area();
Circle c(4);
cout << "Area of circle is " << c.Area();
Square s(5);
cout << "Area of Square is " << s.Area();
Rect r(3,6)
cout << "Area of Rectangle is" << r.Area();
getch();
}