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
Which line of code will print I can code on the screen?
KIM [24]

Answer: print("I can code")

Explanation:

luckily im a coder

5 0
3 years ago
What word describes a violation of copyright laws? What rights do copyright holders have over their work of art
lesya [120]

breech

malefaction

misdoing

offence

transgression

8 0
3 years ago
Read 2 more answers
4. Written record of all transactions in your checking account
Pachacha [2.7K]

Answer:

D) Checkbook register

Explanation:

8 0
3 years ago
Read 2 more answers
Which of the following is a public location that sells Internet access? Internet café Extranet Intranet LogMeIn,
Goshia [24]

Answer:A) Internet cafe

Explanation: Internet cafe is the place that provides the internet service to the public and helps them to access the internet .These cafes can be used by the public who are travelers, people who don't have access at home etc.This internet cafe works on the basis of the hourly rate that it takes from the public.

Rest of the options are incorrect  as intranet and extranet are types of network and LogMeIn is a desktop service .thus, the correct option is option(A).

8 0
3 years ago
In the wireless telecommunications industry, different technical standards are found in different parts of the world. A technica
Serhud [2]

Answer:

A varying infrastructure.

Explanation:

The competitive pressure it creates for multinational companies in the industry is one of difference in infrastructure because different technical standards are found in different parts of the world.

For instance, A technical standard known as Global Systems for Mobile (GSM) is common in Europe, and an alternative standard, Code Division Multiple Access (CDMA), is more common in the United States and parts of Asia.

Consequently, equipment designed for GSM will not work on a CDMA network and vice versa as a result of varying infrastructure, so companies would be innovative in order to improve on their products.

3 0
3 years ago
Other questions:
  • What is the acronym for computerized command provides weather by microphone clicks?
    8·1 answer
  • You type. The word "weather" when you ment "whether" when will the writer or word flag this as a misspelling or a grammar proble
    13·1 answer
  • In controlling network traffic to minimize slow-downs, a technology called ________ is used to examine data files and sort low-p
    15·1 answer
  • In Windows 7/Vista, the information that establishes basic settings such as the location of the operating system and other key s
    7·1 answer
  • How read binary file in c++
    7·1 answer
  • Compose a program to examine the string "Hello, world!\n", and calculate the total decimal numeric value of all the characters i
    7·1 answer
  • Over the past three hours the pressure has been steadily increasing at a rate of what
    6·1 answer
  • Community gardens are public gardens where local residents can grow plants in a plot. They are very popular, so there are often
    7·1 answer
  • Out-of-order instruction execution can cause problems because a later instruction may depend on the results from an earlier inst
    6·1 answer
  • How would you assign roles to your group members?
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!