Write a C++ program to find area of circle,and rectangle using function overloading.
#include<iostream>
using namespace std;
int area(int ,int);
float area(int);
int main()
{
int r;
cout<<"\n enter radius of circul ";
cin>>r;
float A=area(r);
cout<<"\n area of circul "<<A;
int l,b;
cout<<"\n enter length and breadth ";
cin>>l>>b;
int a=area(l,b);
cout<<"\n area of rectangle "<<a;
}
float area(int e)
{
return(3.14*e*e);
}
int area(int l,int b)
{
return(l*b);
}
#include<iostream>
using namespace std;
int area(int ,int);
float area(int);
int main()
{
int r;
cout<<"\n enter radius of circul ";
cin>>r;
float A=area(r);
cout<<"\n area of circul "<<A;
int l,b;
cout<<"\n enter length and breadth ";
cin>>l>>b;
int a=area(l,b);
cout<<"\n area of rectangle "<<a;
}
float area(int e)
{
return(3.14*e*e);
}
int area(int l,int b)
{
return(l*b);
}
No comments:
Post a Comment