# How To Write C++ Program To Calculate Area Of Triangle,circle,square And Rectangle?

## 3 Answers

Ambika ambi answered
#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();
}
thanked the writer.
samina siddiq answered
Include
include
void main()
{
clrscr();
float a,r;
coutr;
a=3.14*(r*r);
cout
thanked the writer.
suresh mahar answered
#include
#include
class area
{
float a,b,c,d;
public:
Void triangle()
{
couta>>b;
cout
thanked the writer.

## Answer Question 