0% found this document useful (2 votes)
4K views

Write A C++ Program To Find Area of Triangle, Circle, and Rectangle Using Function Overloading

This document contains a C++ program that uses function overloading to calculate the areas of different shapes. The program defines three functions - area(float n, float b, float h) to calculate the area of a triangle using base and height, area(float r) to calculate the area of a circle using radius, and area(float l, float b) to calculate the area of a rectangle using length and breadth. It then calls these functions in a main() function to input values, call the appropriate area function based on the shape, and output the calculated areas.

Uploaded by

Ankush Bhaal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (2 votes)
4K views

Write A C++ Program To Find Area of Triangle, Circle, and Rectangle Using Function Overloading

This document contains a C++ program that uses function overloading to calculate the areas of different shapes. The program defines three functions - area(float n, float b, float h) to calculate the area of a triangle using base and height, area(float r) to calculate the area of a circle using radius, and area(float l, float b) to calculate the area of a rectangle using length and breadth. It then calls these functions in a main() function to input values, call the appropriate area function based on the shape, and output the calculated areas.

Uploaded by

Ankush Bhaal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

6/9/2016

23.WriteaC++programtofindareaoftriangle,circle,andrectangleusingfunctionoverloading.|Bedeveloper

Bedeveloper
CuriosityforFindingWhatsNew&Better

23.WriteaC++programtofindareaof
triangle,circle,andrectangleusing
functionoverloading.

i
RateThis

77
37

#include<iostream.h>
#include<conio.h>
constoatpi=3.14;
oatarea(oatn,oatb,oath)
{
oatar;
ar=n*b*h;
returnar;
}
oatarea(oatr)
{
oatar;
ar=pi*r*r;
returnar;
}
oatarea(oatl,oatb)
{
oatar;
ar=l*b;
returnar;
}

https://bedeveloper.wordpress.com/csimpleprogramming/23writeacprogramtofindareaoftrianglecircleandrectangleusingfunctionoverloading/

1/2

6/9/2016

23.WriteaC++programtofindareaoftriangle,circle,andrectangleusingfunctionoverloading.|Bedeveloper

}
voidmain()
{
oatb,h,r,l;
oatresult;
clrscr();
cout<<\nEntertheBase&HieghtofTriangle:\n;
cin>>b>>h;
result=area(0.5,b,h);
cout<<\nAreaofTriangle:<<result<<endl;
cout<<\nEntertheRadiusofCircle:\n;
cin>>r;
result=area(r);
cout<<\nAreaofCircle:<<result<<endl;
cout<<\nEntertheLength&BredthofRectangle:\n;
cin>>l>>b;
result=area(l,b);
cout<<\nAreaofRectangle:<<result<<endl;
getch();
}

BlogatWordPress.com.|TheDuskToDawnTheme.

https://bedeveloper.wordpress.com/csimpleprogramming/23writeacprogramtofindareaoftrianglecircleandrectangleusingfunctionoverloading/

2/2

You might also like