Answer to Question #251322 in C++ for Ali

Question #251322

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. 


1
Expert's answer
2021-10-15T01:28:15-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS