-1

Im new to c++ and this is our first assignment. I dont even know where to start. Help!

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.

Edited by akase2010: n/a

Votes + Comments
I was going to let it slide, but you double-posted it. :(
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by VernonDozier
0

>> I dont even know where to start.

Start by writing a main function that asks the user for input, the passes that value to the function and have the function just return that value. Then print it out in main.

After that works, start writing the real function. Before you do that, put the coding aside and go through the algorithm step by step with pencil, paper, and calculator. When you understand the algorithm, read the spec several times, then implement the function and test.

Edited by VernonDozier: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.