Question: write a program in c++ that will calculate the areaof a circle using the area of right triangles. I'm havingdifficulty figuring out the formula for

write a program in c++ that will calculate the areaof a circle using the area of right triangles. I'm havingdifficulty figuring out the formula for computing the area thatway.

Here is what I have so far:

#include

#include

using namespace std;

const double pi=3.141593;

int main()

{

double r, n_user, n, AOC,AOT; //r=radius, n=number of triangles, AOC=area of circle,AOT=area of triangle

cout<<" Area of a circle computation\n";

cout<<"Please enter the radius of thecircle: ";

cin>>r;

cout<<"Please enter the number oftriangles: ";

cin>>n_user;

AOC=pi*r*r;

cout<

for(n=1; n<=n_user;n++)

{

AOT=n*r*r*sin(360/2*n)*sin(90-360/2*n);

cout<

}

return 0;

}

the problem I am having is that if n is an odd #, it isreturning a negative value. Any ideas?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!