Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Quantum Chemistry

Authors: Ira N. Levine

7th edition

321803450, 978-0321803450

More Books

Students also viewed these Databases questions

Question

Discuss the steps in process planning. AppendixLO1

Answered: 1 week ago