#include<iostream> #include<iomanip> #include<math.h> using namespace std; doubl
ID: 3634629 • Letter: #
Question
#include<iostream>#include<iomanip>
#include<math.h>
using namespace std;
double area(int ,double);
int main()
{
int n;
double side;
cout<<" Enter number of sides: ";
cin>>n;
cout<<" Enter length of side:";
cin>>side;
//calling area with number of sides and side of polygon
cout<<" Area of Regular Plygon: "<<area(n,side)<<" units";
cout<<endl;
system("pause");
return 0;
}
double area(int n,double side)
{
double area;
double PI=3.142;
double num,denom;
//Formula:area=S^2*N/4*tan(PI/n)
//num=S^2*N(say)
//denom=4*tan(PI/n)(say)
num=pow(side,2)*n;
denom=4*tan (PI/n);
area=num/denom;
return area;
}
Explanation / Answer
start
input side
input n
call area of polygon
calculate area based on formula.
return area
print area
end
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.