Answered step by step
Verified Expert Solution
Question
1 Approved Answer
25 points] You've been hired by PI Throwers to write a C++console application that approximates PI. Use a validation loop to prompt and get from
25 points] You've been hired by PI Throwers to write a C++console application that approximates PI. Use a validation loop to prompt and get from the user the number of terms to approximate PI to that is at least 1. Use the following Leibniz PI approximation = 4 * (1/1-1/3 + 1/5-1/7 + 1/9-1/11+ ) The terms appear within the parentheses in the formula. A PI approximation to. One term is 4(1/1) 4 Four terms 4(1/1 1/31/5 1/7)-2.8952380952 Seven terms 4(1/1-1/3 1/5 1/7+1/9-1/111/13) 3.2837384837 Use a for statement to calculate the number that will be multiplied by four. The loop will add and subtract terms to get the number. If i is the indexing variable, use condition i % 2-0 to determine whether each loop iteration is even or odd and whether an add or subtract is done. In each term, the dividend is always 1, and the divisor is an odd number starting with 1 that goes up two at a time. Format the approximation to ten decimal places. Use number of terms 1,000 for your last run
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started