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]
4 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]4 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
Short Essay on the history of Computer​
Ann [662]
Go on a essay website the right a essay about a topic !
5 0
3 years ago
Read 2 more answers
In which situation is coauthoring of presentations primarily utilized?
Tanya [424]

Answer:

A i belive

Explanation:

3 0
3 years ago
Read 2 more answers
Alcohol and drugs
vitfil [10]
I would have to say B
3 0
3 years ago
Two girls were born to the same mother, on the same day, at the same time, in the same month and the same year and yet they're n
Degger [83]

Answer:

They are not twins but triplets or quadruplets.  

Explanation:

3 0
3 years ago
What interior feature is now standard on platinum models for 2022 maxima?
aliya0001 [1]

Answer:

"Heated and Climate-Controlled front seats and steering wheel are standard on SR and Platinum grades."

Explanation:

4 0
2 years ago
Other questions:
  • A person can receive an electric shock by
    15·2 answers
  • When a file has been opened using the 'r' mode specifier, which method will return the file's contents as a string??
    12·1 answer
  • Find an element inside a div using javascript
    12·1 answer
  • "Memory refers to: A.the brain processes involved in the encoding, storage, and retrieval of information. B.the mechanisms drivi
    9·1 answer
  • Why would it be beneficial to preview a page before printing?
    8·1 answer
  • A contact list is a place where you can store a specific contact with other associated information such as a phone number, email
    8·1 answer
  • Individuals and businesses have concerns about data security while using Internet-based applications. Which security risk refers
    7·2 answers
  • What is the difference between Counter Controlled iterations and Sentinel Controlled iterations? What is the purpose of the incr
    8·1 answer
  • Your computer has been showing signs of a malware infection, and today it started up in Safe Mode. Because your computer is not
    6·1 answer
  • When you start an online course, what should you do to make sure you have access to college resources
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!