Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The value of can be approximated with the infinite series as follows: = 4/1 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11.... Write

The value of can be approximated with the infinite series as follows:

= 4/1 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11....

Write a program that determines how many terms in takes using the above infinite series to approximate to 3.14159. You can state the answer to this question in the word document you submit, if you obtain the answer through trial and error.

Bonus (5 points): Your program should stop itself when the precision is met and output the following: It took n terms to approximate pi to 3.14159

Hint: Think about a numerator and a denominator. You learned in a previous homework how togenerate odd number sequences. Pay close attention to the sign of each term. Casting: You can eliminate all numbers beyond the 5th decimal position using casting, such as int a = (int)(3.14159265 *100000). Here a float is being multiplied by an integer, with the result being a float.The decimal point has been moved 5 places to the right. Use (int) to "cast" that into an integer, truncating all the decimals of the new number resulting in the new number 314159.

{{{ Please use only C language and NOT C++ or Java }}| You are also allowed to use the following if needed for loops math.h and pow() function formatting float and double numbers switch statements getchar() function ASCII chart dowhile loops break and continue statements Logical AND (&&), logical OR (||), logical NOT (!) operators

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

Implementing Ai And Machine Learning For Business Optimization

Authors: Robert K Wiley

1st Edition

B0CPQJW72N, 979-8870675855

More Books

Students also viewed these Databases questions