Saturday, 23 June 2012

wirte a c++ program to find area of triangle, circle and ractangle using function overloading

/*wirte a c++ program to find area of triangle, circle and
ractangle using function overloading*/
#include<conio.h>
#include<iostream.h>
void area()
{
int base,len;
float ar;
cout<<"\nenter base and length:-";
cin>>base>>len;
ar=0.5*base*len;
cout<<"\narea of triangle is:-"<<ar;
}
void area(float pi,int r)
{
float ar;
ar=pi*r*r;
cout<<"\narea of circle is:-"<<ar;
}
void area(int l,int b)
{
int ar;
ar=l*b;
cout<<"\narea of ractangle is:-"<<ar;
}
int main()
{
int l,b,r;
float pi=3.14;
clrscr();
area();
cout<<"\nenter radious:-";;
cin>>r;
area(pi,r);
cout<<"\nenter length and breath:-";
cin>>l>>b;
area(l,b);
getch();
return 0;
}
/*

enter base and length:-3 3                                                     
                                                                               
area of triangle is:-4.5                                                       
enter radious:-4                                                               
                                                                               
area of circle is:-50.240002
enter length and breath:-8 5

area of ractangle is:-40
*/

No comments: