write a c program that calculates the area of a


Write a C++ program that calculates the area of a circle, rectangle and square using overloaded versions of a function area ().Your program should include both declarations and definitions of the overloaded versions of 

      the area () function.    Use the main function for input and output.

#include

#include
#include

using namespace std;
double area(double);

double area(double,double);
double area(double,int);

//overloaded functions

double area(double r)

{

const double PI=3.142;
   return PI  * pow(r,2);
 }

double area(double l,double w)

{

return l*w;

}

double area(double l,int n)

{

return pow(l,n)  ;

}

int main()

{

double radius,length,width;

cout<<"Enter the radius of the circle"<>radius;

cout<<"Enter the length and width of the rectangle"<>length>>width;

cout<<"Enter the length of the square"<>length;

cout<<"The area of the circle is:"<      <

cout<<"The area of the rectangle is:"<      <

cout<<"The area of the square is:"<      <

return  0;

}

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: write a c program that calculates the area of a
Reference No:- TGS0158501

Expected delivery within 24 Hours