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
Write a program that will take an integer and add up each of the number’s digits, count the number of digits in the number, and
Inga [223]
For count digits, you could just convert it to a String and check the length
Sum digits, convert to string then seperate each character with charAt then convert it to numbers in the return statement.
Average digits you can convert it to a String and then convert them back after taking them apart.
5 0
2 years ago
Read 2 more answers
Hjnjjjhhbbfg66ui998876dch
GalinKa [24]
What is your question? I’ll try my best to help
4 0
2 years ago
Jenn wants to assign a value to the favorite car variable: favoriteCar = Toyota but gets an error message. What does she need to
Bumek [7]

Answer:

The correct answer is: Option d: Put Quotation marks around the string.

Explanation:

The names of things or places or cars are usually in the form of words or sentences. The words or sentences are stored in string datatype.

Quotation marks are used to deal with strings in programming languages.

Hence,

The correct answer is: Option d: Put Quotation marks around the string.

3 0
3 years ago
9. Government and corporate officials concerned about security threats do not bring their own cell phones or laptops when travel
tatuchka [14]

Answer:

True

Explanation:

It is known as Don-Not-Carry rules are implemmented to avoid

-Unauthorized full disk copies (it have been made while the laptop owner was out of the hotel room on overseas travel)

-Laptops steals

- Monitoring by third parties of wireless using.

3 0
3 years ago
Consider the following method: public double doubleVal(double x) { return x *2; } The following code segment calls the method do
VashaNatasha [74]

Answer:

13.0

Explanation:

The method doubleVal() is created to accept a single parameter of type double.

It multiplies what ever the value of the parameter is and returns the resulting value.

In this question The method is called within this output statement System.out.println(doubleVal(val)); (Note that val had already been declared and assigned the value of 6.5)

The value 6.5 is doubled and outputed to the screen

8 0
2 years ago
Other questions:
  • PPPLLLLEEEEAAASSSSEEEEE HHELLP me.Does anyone know how to copy an image onto a thing so i can post a real question on brainly. b
    8·2 answers
  • Ryan has created a Word document to be used as a review quiz for students in a classroom setting. The document contains both que
    6·1 answer
  • A flat-panel detector is exposed with nothing between the x-ray tube and detector. 5 images were acquired on 5 different days us
    6·1 answer
  • What is logical memory?
    15·1 answer
  • The Spanning Tree Protocol operates at the Network layer of the OSI model.
    13·1 answer
  • When using correct ergonomic technique be sure to _____.
    11·2 answers
  • One tool under What-If-Analysis is Scenarios. Which best describes the purpose of setting up and using scenarios
    5·1 answer
  • BRAINLIEST!!! 20 PNTS!!!! HELPP!!!
    12·1 answer
  • Brainliest for correct answer
    13·2 answers
  • Consider the following declaration:
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!