A program to find the area of circle and rectangle using the concept of function overloading in C++

#include<iostream>
using namespace std;
class Areas
{
public:
void Area(float l, float b)
{
cout<<“Area of rectangle=\t”<<l*b;
}
void Area(float r)
{
cout<<“Area of circle=\n”<<3.14*r*r;
}
};
int main()
{
float l,b,r;
Areas a1;
cout<<“enter length and breadth\n”;
cin>>l>>b;
a1.Area(l,b);
cout<<“enter the radius\n”;
cin>>r;
a1.Area(r);
}

Output:

Leave a Reply

Your email address will not be published. Required fields are marked *