Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can somebody help me with this.I need it asap. Write a C program that computes Pi with the approximation algorithm that I introduced in class.

Can somebody help me with this.I need it asap.image text in transcribed

Write a C program that computes Pi with the approximation algorithm that I introduced in class. I want you to write the program in two different ways The first version will add up the first 28284277 elements of the approximation series in a simple for loop. I ask you to put the code into a function with this signature: float get pi for(void); The second version will break out of a while loop depending on whether a pair of adjacent elements (remember that we always consider a positive element and its adjacent negative right neighbor) is smaller than a certain threshold. I ask you to use the threshold 0.00000000000001. Please put the code of this version into a function with the signature float get pi while(void); . . Put both functions into a file called pi.c. Also write a corresponding header file that has symbolic constants for both the number of LOOPS to be run as well as for the THRESHOLD value. Finally, vrite a file main.c that contains the driver, which will print out pi twice calling the two different functions. I want you to call get pi for0 first, then call get pi while0. Write a C program that computes Pi with the approximation algorithm that I introduced in class. I want you to write the program in two different ways The first version will add up the first 28284277 elements of the approximation series in a simple for loop. I ask you to put the code into a function with this signature: float get pi for(void); The second version will break out of a while loop depending on whether a pair of adjacent elements (remember that we always consider a positive element and its adjacent negative right neighbor) is smaller than a certain threshold. I ask you to use the threshold 0.00000000000001. Please put the code of this version into a function with the signature float get pi while(void); . . Put both functions into a file called pi.c. Also write a corresponding header file that has symbolic constants for both the number of LOOPS to be run as well as for the THRESHOLD value. Finally, vrite a file main.c that contains the driver, which will print out pi twice calling the two different functions. I want you to call get pi for0 first, then call get pi while0

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

Students also viewed these Databases questions