Bright Tsorhey
8 years ago

write a function in cpp to calculate the area of a circle, rectangle and a triangel

Solution (By Examveda Team)

#include&lf;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"< cout<<"nArea of rectangle is "< cout<<"nArea of circle is "< cout<<"nArea of triangle is "< return 0;
}
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);
}

This Question Belongs to User Ask Question >> Miscellaneous

Join The Discussion

Related User Ask Questions