1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Kazeer [188]
3 years ago
15

Write a C++ program that computes an approximation of pi (the mathematical constant used in many trigonometric and calculus appl

ications) to four decimal places. A summation that can be used to compute pi is the following (from calculus). pi = 4/1 - 4/3 + 4/5 - 4/7 + 4/9 - ....... + (-1)ⁿ * 4/ (2n+1)Your program will compute a sequence of computations: S₀ = 4/1 S₁ = S₀ - 4/3 S₂ = S₁ + 4/5Since the above sequence So, S1, S2, ... converges to pi, we can stop when two consecutive S values differ by less than 0.00005.
Computers and Technology
1 answer:
Verizon [17]3 years ago
3 0

Answer:

#include <iostream>

#include<cmath>

using namespace std;

int main()

{

double total = 0;

double check=1;

double ct=0;

double old=1;

while( fabs(total - old) > 0.00005 )

{

old=total;

total=total+check*4.0/(2.0*ct+1);

ct=ct+1;

check=0.0-check;

}

cout<<"Approximate value of pi is "<<total<<endl;

return 0;

}

Explanation:

  • Initialize all the necessary variables.
  • Run a while loop until the following condition is met.

fabs(total - old) > 0.00005

  • Inside the while loop calculate the total value.
  • Lastly, display the approximate value of pi.
You might be interested in
The Chairman of the Federal Reserve &amp; the Federal Open Market Committee determine the percentage of a deposit which must be
Scrat [10]
Required Deposit Reserve
6 0
3 years ago
Choose the type of collection created with each assignment statement
Leviafan [203]

Answer:

dictionary

tuple

list

Explanation:

4 0
3 years ago
Which statements accurately describe tropical rain forests
sattari [20]

The tropical rain forest is a forest of tall trees in a region of year-round warmth. An average of 50 to 260 inches of rain falls yearly. Rain forests belong to the tropical wet climate group.

Explanation:

  • The temperature in a rain forest rarely gets higher than 93 °F or drops below 68 °F. The average humidity is between 77 and 88%, rainfall is often more than 100 inches a year. In monsoonal areas, there is a real dry season.
  • Rainforests now cover less than 6% of Earth's land surface. Tropical rainforests produce 40% of Earth's oxygen.
  • About 1/4 of all the medicines we use come from rainforest plants. Curare comes from a tropical vine, is used as an anesthetic and to relax muscles during surgery. Quinineis used to treat malaria.
  • There are four very distinct layers of trees in a tropical rain forest. They are the emergent, upper canopy, understory, and forest floor.
  • The soil of the tropical rainforests is shallow, poor in nutrients and without soluble minerals. Years of rainfall have washed away the nutrients in the soil obtained from weathered rocks.
  • The tropical rain forest can be found in three major geographical areas around the world.
  • Central America in the the Amazon river basin.  Africa - Zaire basin, with a small area in West Africa. Indo-Malaysia - west coast of India, Assam, Southeast Asia, New Guinea and Queensland, Australia.
7 0
3 years ago
What are the steps involved in accepting all the changes in a document?
Makovka662 [10]

To accept all the changes in a document click Accept All.

4 0
3 years ago
Read 2 more answers
1. What is the global marketplace?
podryga [215]

.......................................

4 0
3 years ago
Read 2 more answers
Other questions:
  • What is the "host" in a typical email address?
    14·1 answer
  • what is the restaurant with the black pom tree and yellow backround three letter name from hi guess the restaurant
    14·2 answers
  • Explain the function of the Ribbon in Microsoft Word.
    15·1 answer
  • Generate the requested sets using only set builder notation and the provided sets. Some problems may require you to build one or
    15·1 answer
  • Why is brainly not working it say im logged out rn but im not i cant acces anything but this
    12·2 answers
  • Which of the following best meets the requirements of a strong password?
    5·2 answers
  • You can access various sites on WWW by using hyperlinks or by?
    6·2 answers
  • How many total bits are required for a direct mapped cache with 16 KB of data and 4 word blocks Assuming a 32 bit address
    12·1 answer
  • Does anyone know 7.1.3: Firework karel?
    5·1 answer
  • To meet the requirement for the number of vdss on board, what must be true about pyrotechnic vdss?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!