Your task is to write a main program which asks the user for an error value and then calls a function CalculatePi (error) which returns an approximate value of π.

The function CalculatePi should use a loop to calculate the above series (*). It should keep two values, currentApproximation and nextApproximation. Initially currentApproximation = 4. The loop should keep adding and subtracting terms until the difference between currentApproximation and nextApproximation is less than error. It should then return currentApproximation.

alex55 commented: beggar +0

This is not the appropriate place to beg for code.

commented: I prefer to give +rep today :) +5
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.