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
To pinpoint an earthquake's location, scientists need information from how many seismometers?
Mazyrski [523]
<span>C. 3
   Due to the different speeds of P and S waves, a single seismometers can determine the distance to an earthquake. So, for a single station, the localization is any point on a circle around the station. With 2 stations, you'll have two circles that intersect at two points. The 3rd station is needed in order to determine which of the 2 points is the actual earthquake.</span>
7 0
3 years ago
Please help...........​
MrMuchimi

Answer:

Explanation:

As a user of GPL v3 software, you have lots of freedom: You can use GPL software for commercial purposes. You can modify the software and create derivative work. You can distribute the software and any derivative work you produce, without having to ask for permission or pay

4 0
3 years ago
Read 2 more answers
What are the pros and cons of using the internet in a medical office setting?
Shkiper50 [21]
Pros: are doctors are able to educate themselves in order to diagnose a patient, it's fast and convenient to put in records, medical facilities can transfer information from different locations etc.

Cons: the system can breached, this could leak health and personal information from patients, and the power could go down, delaying the use of signing in patients and etc
5 0
3 years ago
When you reboot your system, the computer follows start-up instructions stored in this type of memory. multiple choice dram sdra
MA_775_DIABLO [31]
<span>A computer’s start-up instructions are stored in a type of memory called Flash. Flash memory can be written to and read from, but its contents are not erased after the computer powers down. This Flash memory is more commonly referred to as the BIOS (Basic Input Output System).</span>
4 0
4 years ago
Read 2 more answers
_____ specifies the format of a mail message and describes how mail is to be administered on the e-mail server and transmitted o
Hitman42 [59]

Answer:

SMTP (Simple Mail Transfer Protocol) specifies the format of a mail message and describes how mail is to be administered on the e-mail server and transmitted on the Internet

Explanation:

SMTP (Simple Mail Transfer Protocol)  is the protocol for the e-mail transmission over the internet.

The e-mails we send is forwarded over the SMTP, directed to the email servers.

SMTP does its job by breaking the email message into several categories so that the receiving server can understand how to deal with the e-mail message.

6 0
3 years ago
Other questions:
  • When do images or graphics in Microsoft Word hurt the document rather than help
    9·1 answer
  • What type of data can we enter in a spreadsheet?
    11·1 answer
  • This is more opinionated than question-based.
    7·1 answer
  • The Status bar is used to control the majority of the drafting settings in AutoCAD
    13·1 answer
  • To execute a prepared SQL statement, you can use the ________________ and execute() methods of the PDOStatement object to set pa
    10·1 answer
  • Technology changes rapidly. Do you think the development of new technology will slow down at some point? At some point will cons
    12·1 answer
  • A peripheral can be used to tell a computer to complete a specific task.<br> A) True <br> B)False
    13·1 answer
  • Formatting means ____________
    12·2 answers
  • Anyone know how to fix this problem on Microsoft Team?
    14·2 answers
  • Which generation of computer is most popular and why?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!