0% found this document useful (0 votes)
93 views

CPP Triangle, Circle Rectangle Function Overloading

This C++ program uses function overloading to calculate the areas of different shapes. It defines integer and float functions called "area" to calculate the area of a rectangle based on length and breadth, the area of a circle based on radius, and the area of a triangle based on base and height. The main function gets input for the dimensions of these shapes and outputs the calculated areas by calling the appropriate area functions.

Uploaded by

Nikhil Kamble
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
93 views

CPP Triangle, Circle Rectangle Function Overloading

This C++ program uses function overloading to calculate the areas of different shapes. It defines integer and float functions called "area" to calculate the area of a rectangle based on length and breadth, the area of a circle based on radius, and the area of a triangle based on base and height. The main function gets input for the dimensions of these shapes and outputs the calculated areas by calling the appropriate area functions.

Uploaded by

Nikhil Kamble
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Cpp Triangle, circle rectangle function overloading

Below is the source code for C++ program to find Area using Function Overloading
which is successfully compiled and run on Windows System to produce desired output
as shown below :

#include<iostream>
using namespace std;
int area(int,int);
float area(float);
float area(float,float);
int main()
{
int l,b;
float r,bs,ht;

cout<<"Enter length and breadth of rectangle:";


cin>>l>>b;
cout<<"Enter radius of circle:";
cin>>r;
cout<<"Enter base and height of triangle:";
cin>>bs>>ht;

cout<<"\nArea of rectangle is "<<area(l,b);


cout<<"\nArea of circle is "<<area(r);
cout<<"\nArea of triangle is "<<area(bs,ht);

}
int area(int l,int b)
{
return(l*b);
}
float area(float r)
{
return(3.14*r*r);
}
float area(float bs,float ht)
{
return((bs*ht)/2);
}

You might also like