Area of a circle is π × r2 where r = radius
Area of a triangle is ½ × b × h where b = base, h = height
Area of a rectangle is w × h w = width, h = height
Area of a square is a
2 where a = length of side
Write four different functions with same name that is Area to calculate the area of
circle, triangle, rectangle and square.
#include<iostream>
using namespace std;
void Area()
{
int r,l,h,len;
cout<<"Enter the radius: "<<endl;
cin>>r;
double area=22/7*r*r;
cout<<"Area of circle is: "<<area;
int b,h1;
cout<<"\nEnter the base and the height: "<<endl;
cin>>b>>h1;
double ar=0.5*b*h1;
cout<<"Area of triangle is: "<<ar;
cout<<"\nEnter the Length and the heigth: "<<endl;
cin>>l>>h;
cout<<"\nThe area of the rectangle is: "<<l*h;
cout<<"\nEnter the length: ";
cin>>len;
cout<<"\nThe area of the Square is: "<<len*len;
}
int main()
{
Area();
return 0;
}
Comments
Leave a comment