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
What is activated as necessary to support local eocs and to ensure that responders have the resources they need to conduct respo
gizmo_the_mogwai [7]

Answer: Emergency Operation Center (EOC)

Explanation:

An Emergency Operation Center is the coordination base for emergency service in case there is any within a state or a state Connecticut. The major purpose of the emergency center is to be in charge of controlling deploying and utilizing facilities needed to prepare for any form of emergency, disaster management, etc.

To run an effective Emergency Operation Center, focus must be on the facilities, equipments and personnel involved.

3 0
3 years ago
I have six nuts and six bolts. Exactly one nut goes with each bolt. The nuts are all different sizes, but it’s hard to compare t
juin [17]

Answer:

Explanation:

In order to arrange the corresponding nuts and bolts in order using quicksort algorithm, we need to first create two arrays , one for nuts and another for bolts namely nutsArr[6] and boltsArr[6]. Now, using one of the bolts as pivot, we can rearrange the nuts in the nuts array such that the nuts on left side of the element chosen (i.e, the ith element indexed as nutArr[i]) are smaller than the nut at ith position and nuts to the right side of nutsArr[i] are larger than the nut at position "I". We implement this strategy recursively to sort the nuts array. The reason that we need to use bolts for sorting nuts is that nuts are not comparable among themselves and bolts are not comparable among themselves(as mentioned in the question)

The pseudocode for the given problem goes as follows:

// method to quick sort the elements in the two arrays

quickSort(nutsArr[start...end], boltsArr[start...end]): if start < end: // choose a nut from nutsArr at random randElement = nutsArr[random(start, end+1)] // partition the boltsArr using the randElement random pivot pivot = partition(boltsArr[start...end], randElement) // partition nutsArr around the bolt at the pivot position partition(nutsArr[start...end], boltsArr[pivot]) // call quickSort by passing first partition quickSort(nutsArr[start...pivot-1], boltsArr[start...pivot-1]) // call quickSort by passing second partition quickSort(nutsArr[pivot+1...end], boltsArr[pivot+1...end])

// method to partition the array passed as parameter, it also takes pivot as parameter

partition(character array, integer start, integer end, character pivot)

{

       integer i = start;

loop from j = start to j < end

       {

check if array[j] < pivot

{

swap (array[i],array[j])

               increase i by 1;

           }

 else check if array[j] = pivot

{

               swap (array[end],array[j])

               decrease i by 1;

           }

       }

swap (array[i] , array[end])

       return partition index i;

}

7 0
3 years ago
Which sentence describes a task on which a genetic engineer is most likely to work?
galina1969 [7]

Answer:

C

Explanation:

If you look at the picture, you will see why it is C. It says D, but the multiple choices are differently ordered and it is kind of differently worded.

But in conclusion, the answer is C.

5 0
3 years ago
Read 2 more answers
Which is the best description of a computer virus?
MatroZZZ [7]
The best description of a computer virus is. Someone first starts out making a malicious program, then can send it to a unexpected user. After that, when the user opens the malicious program, it can do negative things on the target. The virus first starts out in the system32, then infects a random file type for example, exe files, or dlls etc. Then random errors can pop up on the computer saying "YOUR COMPUTER IS UNDER RISK! CALL THIS NUMBER NOW! 555-555-5555" and the options of the error, can direct you to a website, that can give you another virus. To get rid of a virus, you have to ignore the popups that comes onto your computer, and get a strong antivirus like avast, or avg. Then let it scan the system. After when the scan is done, it will show up the virus, and it will give you options "to delete virus or ignore it" you would hit delete. I hope this answer helped you. Let me know if you have any more questions! Thanks!
6 0
2 years ago
Read 2 more answers
20 points!!
creativ13 [48]
I think it’s C considering what clip art is, you put in pictures. i’m crying with you
3 0
2 years ago
Other questions:
  • What is special about the f and j keys on a standard keyboard?
    15·2 answers
  • How to use javascript libraries in javascript code?
    9·1 answer
  • How long before a speech should you begin practicing?
    10·2 answers
  • What takes information entered into a given system and sends it automatically to all upstream systems and processes?
    6·2 answers
  • When adding cells you must use a "+" symbol, you cannot use a ":" symbol.<br><br> ☐ True<br> ☐ False
    13·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
  • In QBasic, create a number guessing challenge. Your program should generate a random number from 1-
    9·1 answer
  • ! (( i &gt; ( f + 1)) es verdadero o falso segun la logica de programación.
    14·1 answer
  • How to transfer polygon from eth to polygon in ledger live
    6·1 answer
  • Create a timeline of the evolution of computers and their impact on society
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!