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
This technology was developed in the 1980s and was a successful attempt to provide services for voice, video, and video traffic
sveticcg [70]

Answer:

SONET was the only one on the list created near the 1980s (1985)

Good luck!

<em>~Awwsome</em>

8 0
3 years ago
What is the purpose of citations?
Elina [12.6K]

Answer: Citiations areto show where you got information from.

Explanation:

6 0
3 years ago
Rows within a spreadsheet are identified by:
EleoNora [17]

Answer:

Option C: Numbers.

Explanation:

By default, rows within a spreadsheet are identified by Numbers i.e. 1,2,3,............

Total rows are 1048575 in one spreadsheet.

7 0
3 years ago
Which of the following is a characteristic of the college savings plan
Hoochie [10]

add the choices please

8 0
3 years ago
Read 2 more answers
Java and Python are considered rapid development programming languages?<br><br> True<br><br> False
Zepler [3.9K]
That is true because Java was considered a rapid development programming language
8 0
3 years ago
Read 2 more answers
Other questions:
  • What is a technology that exists inside another device called
    11·1 answer
  • Write a program that allows a user to input words at the command line. Your program should stop accepting words when the user en
    10·1 answer
  • Who began digitizing books on a massive scale and putting them online?
    8·1 answer
  • Write a function findWithinThreshold that identifies the elements of a given array that are inside a threshold value. Takes the
    13·1 answer
  • "What is the capital of Belarus?" is an example of what type of search query
    10·2 answers
  • What means the data is still saved even if you turn the computer off or unplug it?​
    5·1 answer
  • (Display characters) Write a method that prints characters using the following header: public static void printChars(char ch1, c
    6·2 answers
  • What complications are imposed if one tries to implement a dynamic list using a traditional one-dimensional array
    14·1 answer
  • Which browser feature will delete your history, cache, and cookies the moment you close the special window
    6·1 answer
  • What happened to China and India after they modernized their workforces by providing more training and education?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!