C++ programs(function overloading)

#include<iostream.h>
#include<conio.h>
#include<math.h>
int area(int x);
float area(float x);
int area(int x, int y);
float area(int x,int y,int z);

void main()
{
clrscr();
int x,a,b,c,L,B;
float r;
cout<<“enter the side of square:-“;
cin>>x;
cout<<area(x);
cout<<“\nenter the radius of circle in decimal form:-“;
cin>>r;
cout<<area(r);
cout<<“\nenter the sides of rectangle:-“;
cin>>L>>B;
cout<<area(L,B);
cout<<“\nenter the sides of traingles:-“;
cin>>a>>b>>c;
cout<<area(a,b,c);
getch();
}
int area(int x)
{
return(x*x);
}
float area(float x)
{
return(3.14*x*x);
}
int area(int x, int y)
{
return(x*y);
}
float area(int x,int y,int z)
{
float s;
s=((x+y+z)/2);
return(sqrt(s*(s-x)*(s-y)*(s-z)));
}

Comments

Popular Posts