Computer Science, asked by manasakavala2850, 1 year ago

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

Answers

Answered by LEGEND200
18

Answer:

#include<iostream>

using namespace std;

int area(int);

int area(int,int);

float area(float);

float area(float,float);

int main()

{

int s,l,b;

float r,bs,ht;

cout<<"Enter side of a square:";

cin>>s;

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<<"Area of square is"<<area(s);

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 s)

{

return(s*s);

}

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);

}

Explanation:

Sample Input

Enter side of a square:2

Enter length and breadth of rectangle:3 6

Enter radius of circle:3

Enter base and height of triangle:4 4

Sample Output

Area of square is4

Area of rectangle is 18

Area of circle is 28.26

Area of triangle is 8

Answered by mrunalpimpale55
6

Answer:

Explanation:

I don't understand

Sorry

Similar questions