Question: in c code Outputs The mathematical constant PI is a fascinating subject area and several different algorithms exist for its approximation to a given precision.
in c code

Outputs





The mathematical constant PI is a fascinating subject area and several different algorithms exist for its approximation to a given precision. In this problem, we will be looking at two such methods for computing Pl: Madhava's method and Euler's method. Write a driver program that uses the following two functions (based on Madhava's and Euler's methods) to compute the value of Pl. Let the user specify how many iterations the functions should use. The function prototypes are specified as such: double piBy Madhava(int noflterations): double pi By Euler (int noflterations); Following is the formula for Madhava's method. 1-1- + - +.... Following is the formula for Euler's method. + + + + .... The driver program displays the output obtained from the Madhava's and Euler's methods, as well as the value obtained from the math library Sample Output: Enter number of iterations: 1000 Approximation of PI using Madhava's method: 3.140592653840 Approximation of PI using Euler's method: 3.140637100986 Math library approximation of PI: 3.141592653590 Data Type Requirement: Input data is of type int and output type is double. Input Validation: We will always run at least one iteration. Enter the number of iterations to run the program: 1 PI (Madhava ) = PI (Euler ) = PI (math library) = 4.000000000000 2.449489742783 3.141592653590 Enter the number of iterations to run the program: 1000 PI (Madhava ) = PI (Euler ) = PI (math library) = 3. 140592653840 3.140638056206 3.141592653590 Enter the number of iterations to run the program: 8 PI (Madhava ) = PI (Euler ) = PI (math library) = 3.017071817072 3.027297856658 3.141592653590 Enter the number of iterations to run the program: -4 Number of iterations must be at least 1 Enter the number of iterations to run the program: 15 PI (Madhava ) = PI (Euler ) = PI (math library) = 3.208185652262 3.079389826032 3. 141592653590
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
