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
Alex777 [14]
3 years ago
13

Write a c++ program to calculate the approximate value of pi using this series. The program takes an input n that determines the

number of values we are going to use in this series. Then output the approximation of the value of pi. The more values in the series, the more accurate the data. Note 5 terms isn’t nearly enough. You will try it with numbers read in from a file. to see the accuracy increase. Use a for loop for the calculation and a while loop that allows the user to repeat this calculation for new values n until the user says they want to end the program.
Create an input file with nano lab04bin.txt


12


123


1234


12345


123456


1234567


12345678


123456789


It has to be written in c++
Computers and Technology
1 answer:
Tanya [424]3 years ago
6 0

Answer:

#include <iostream>

#include <iomanip>

using namespace std;

int main() {

  char choice;

  cout << setprecision(12) << endl;

  while(true) {

      int sign = 1;

      double pi = 0;

      cout << "Enter number of terms: ";

      long n;

      cin >> n;

      for(long i = 1; i < n; i += 2) {

          pi += sign/(double)i;

          sign = -sign;

      }

      pi *= 4;

      cout << "value of pi for n = " << n << " is " << pi << endl;

      cout << "Do you want to try again(y or n)? ";

      cin >> choice;

      if(choice == 'n' || choice == 'N') {

          break;

      }

  }

  return 0;

}

Explanation:

You might be interested in
Allison needs to graph the yearly average snowfall in Alaska. She should use a:
bazaltina [42]

C: bar graph

bar graphs are used to track changes over time, so I would say that C is your best bet

7 0
3 years ago
Read 2 more answers
One of the disadvantages of cable technology is that:
Artemon [7]

Answer:

The answer is letter C

Explanation:

Systems used by many providers require customers to share bandwidth with neighbors

8 0
2 years ago
When you open a program, the hard drive___
Papessa [141]

Answer:

When you open a program, the hard drive <u>Registers the program and runs the program accordingly. </u>

I hope this helped!

3 0
3 years ago
3. Touch screens are both input and output devices. Describe one application where a touch screen is used as an output device. (
defon

Answer:

Mobile phone

Explanation:

Hopefully this is right

7 0
3 years ago
Read 2 more answers
Help me<br>please answers this questions<br>​
kobusy [5.1K]

Answer:

RSI stands for repeating similar movements

3 0
2 years ago
Other questions:
  • You can apply bold, italic, and underline styles to text. But why is it a good idea to use underline sparingly?
    13·2 answers
  • . String literals are surrounded by _____ quotes
    14·1 answer
  • 1. [2 points] Write a function to compute the volume of a sphere, given its radius. 2. [2 points] Write a recursive function to
    7·1 answer
  • Setting the isShowing property to false of the opacity property to o will delete an object from an Alice world.
    15·2 answers
  • Complete the sentence.
    8·1 answer
  • To indent an entire paragraph or list you should:
    9·1 answer
  • Lucas wants to expand his vocabulary to better understand the sentence below. The insidious burglar moved through the house unhe
    7·2 answers
  • Fort Nite is the best u can’t say it’s not
    13·2 answers
  • Fundamental of Computer Science
    15·1 answer
  • Look at the code in the example below, and then answer the question.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!