#include <iostream>
using namespace std;
#define pi 3.14159265359
Don't use plagiarized sources. Get Your Custom Essay on
Area Calculator: Write a program to calculate the area of some simple geometric shapes. The shapes required to be…
Get an essay WRITTEN FOR YOU, Plagiarism free, and by an EXPERT!
void rectangleArea(double l, double w)
{
cout<<“nArea of the rectangle is “<<l*w<<endl;
}
void circleArea(double r)
{
cout<<“nArea of the circle is “<<(pi*r*r)<<endl;
}
void rightTriangleArea(double h, double b)
{
cout<<“nArea of the right triangle is “<<h*b/2<<endl;
}
int main() {
double length, width, radius;
cout<<“Calculating area for rectangle…”<<endl;
cout<<“Enter length: “;
cin>>length;
cout<<“nEnter width: “;
cin>>width;
rectangleArea(length, width);
cout<<“nCalculating area for circle…”<<endl;
cout<<“Enter radius: “;
cin>>radius;
circleArea(radius);
cout<<“nCalculating area for right triangle…”<<endl;
cout<<“Enter base: “;
cin>>width;
cout<<“nEnter height: “;
cin>>length;
rightTriangleArea(length, width);
return 0;
}
OUTPUT:
Calculating area for rectangle...
Enter length: 10
Enter width: 20
Area of the rectangle is 200
Calculating area for circle...
Enter radius: 5
Area of the circle is 78.5398
Calculating area for right triangle...
Enter base: 12
Enter height: 20
Area of the right triangle is 120