Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ program to compute the value of PI based upon the Gregory-Leibniz Series given the number in the series. One of the most

Write a C++ program to compute the value of PI based upon the Gregory-Leibniz Series given the number in the series.

"One of the most well known and beautiful ways to calculate Pi () is to use the Gregory-Leibniz Series:

image text in transcribed"

Make sure your program conforms to the following requirements: 1. This program should be called computePI.cpp 2. Accept the sequence number from the user (as an integer). 3. Do not allow the program to continue until the sequence number selected by the user is positive (at least 1). 4. Compute and print the value of PI using the Gregory-Leibniz Series up to the sequence number entered by the user. 5. Add comments wherever necessary.

Sample Runs:

NOTE: not all possible runs are shown below.

Sample Runs:

Welcome to the compute PI program... What is the sequence number?-9 What is the sequence number? (must be an integer > 0)0 What is the sequence number? (must be an integer > 0)-6 What is the sequence number? (must be an integer > 0)30000 3.141559320256469190054890439078860708832508

Welcome to the compute PI program... What is the sequence number?65 3.156976358911272252617472022784284035878954

Welcome to the compute PI program... What is the sequence number?1000000 3.14159165358979318525417534502253147365991

+ +

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database System

Authors: Elmasri Ramez And Navathe Shamkant

7th Edition

978-9332582705

More Books

Students also viewed these Databases questions