Sunday, December 7, 2014

Write a C++ program to find area of triangle, circle,and rectangle using function overloading

#include<iostream>
using namespace std;

const float pi=3.14;
float area(float n,float b,float h)
float area(float x,float y,float z)
{
float ar;
ar=x*y*z;
cout<<"The area of Triangle : "<<ar<<endl<<endl;
}
float area(float n)
{
float ar;
ar=pi*n*n;
cout<<"The area of Circle : "<<ar<<endl<<endl;
}
float area(float l,float w)
{
float ar;
ar=m*w;
cout<<"The area of Rectangle :"<<ar<<endl;
}
int main()
{
float y,z,n,l,w;

cout<<"Enter the Base & Hieght of Triangle : ";
cin>>y>>z;
area(0.5,y,z);

cout<<"Enter the radius of circle :";
cin>>n;
area(n);


cout<<"Enter the Lenght & width of Rectangle: ";
cin>>l>>w;
area(l,w);
return 0;
}

No comments:

Post a Comment