write a program in c++ that will calculate the areaof a circle using the area of right
Fantastic news! We've Found the answer you've been seeking!
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 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?
Related Book For
Posted Date: