#include<iostream>
using namespace std;
int showmenu();
float area(double rad);
float area(float side);
float area(float length, float width);
void main()
{
int x;
float arr, side, length, width;
double radius;
x = showmenu();
if (x == 1)
{
cout << "Enter the radius of the circle: ";
cin >> radius;
arr = area(radius);
}
else if (x == 2)
{
cout << "Enter the length of the side of the sqaure: ";
cin >> side;
arr = area(side);
}
else if (x == 3)
{
cout << "Enter the length of the side of the rectangle: ";
cin >> length;
cout << "Enter the width of the side of the rectangle: ";
cin >> width;
arr = area(length, width);
}
else
{
cout << "Incorrect choice" << endl;
return;
}
cout << "Area = " << arr << endl;
system("pause");
}
int showmenu()
{
int ch;
cout << "Enter 1 to calculate area of a circle." << endl;
cout << "Enter 2 to calculate area of a square." << endl;
cout << "Enter 3 to calculate area of a rectangle." << endl;
cout << "Enter your choice: ";
cin >> ch;
return ch;
}
float area(double rad)
{
float area;
area = (22 * rad * rad) / 7;
return area;
}
float area(float side)
{
float area;
area = side * side;
return area;
}
float area(float length, float width)
{
float area;
area = length * width;
return area;
}