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
The carbon fixation reaction converts?​
Ainat [17]

Answer:

Photosynthetic carbon fixation converts light energy into chemical energy. Photosynthesis reduces the carbon in carbon dioxide from OSC = +4 to OSC = +1 in the terminal carbon in glyceraldehyde-3-phosphate, the feedstock for simple sugars, amino acids, and lipids.

3 0
3 years ago
Something you want to learn in Computer Science for Innovators and Makers is…
zhenek [66]

Answer:

that is classified information

Explanation:

that is a weird question

6 0
3 years ago
Read 2 more answers
Explain the HTTP protocol in your own words. (up to 150 words
-BARSIC- [3]

Answer:

HTTP protocol is basically stand for the hyper text transfer protocol. It is an application protocol that is basically distributed and collaborative. The hypertext transfer protocol is the foundation of the data communication in the WWW( world wide web).

It is basically work between the client and the server as the request response.

It is generally used in the transmission control protocol (TCP) for the communication with the server. The HTTP is basically used in the wireless communication.

3 0
3 years ago
A company's ____________ is the percentage of the total target market for the product that belongs to the company.
grigory [225]

a companys Market share is the percentage of the total target market for the product that belongs to the company

3 0
3 years ago
Where on a computer is the operating system generally stored?
Brilliant_brown [7]

The operating system on a computer is generally stored at hard disk.

4 0
3 years ago
Other questions:
  • Search the internet for news of a motor vehicle collision in your community involving drugs or alcohol. Keeping in mind that you
    8·1 answer
  • A technician has been notified of a problem on the network. After investigation, the technician determines that a specific inter
    7·1 answer
  • B. Does “refactoring” mean that you modify the entire design iteratively? If not, what does it mean?
    7·1 answer
  • ) A popular PivotChart that is used in Access is (Points : 4) column.
    9·1 answer
  • Which of the following is not a hazard a driver might encounter?
    5·1 answer
  • A web designer is creating a web site and wants each browser to resize the text size to look the same in each device. what measu
    6·1 answer
  • Which of these is the fastest transmission medium?
    11·2 answers
  • Name any four areas where computers are used​
    15·1 answer
  • If “A” represents in binary 10011001, what will be the value of word “CAB”?
    15·1 answer
  • Which is a major drawback of muliuser procesing of a database
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!