Question: Approximating One num erica! algorithm to compute an approximation to the constant involves computing the value of the following sum. N-1 N) (14() where the
Approximating One num erica! algorithm to compute an approximation to the constant involves computing the value of the following sum. N-1 N) (14() where the value N controls the number of steps (and larger values will result in better approxima- tions). Recall from the labs that a numerical summation like the one above can be implemented with a C for or while loop (using extra variables inside the loop to break down the formula into manageable parts). 2.1 Your Task Write a syntactically and semantically correct C program which uses'the formula above to compute several different approximations of using the formula above for N = 10,100 1000 10000 100000 and 1000000. Notice that at each step, the value of N is multiplied by 10. Your code should be stored in a file called "pi.c". To receive full marks, your code should contain as little duplication as possible (and, in particular, should not contain more than one copy of the loop which evaluates the formula above). You will likely need to use nested loops to accomplish this task. 3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
