#WSQ14

In this program you need to estimate the constant “e”, to do this you need to ask the user the number of decimals points, and that will be your precision.

If you want to know about the formula that we are going to use and things about that, you can check this page: http://www.iboenweb.com/ibo/docs/Demostracion%20de%20Formula%20de%20Euler.htm

To organize the program I created a function called factorial, to calculate the factorial that will be introduced in the function calculateE.

The function calculateE is float, because is going to return a non integer number.

The loop do-while, inside the function calculateE, is useful to add the value according with the formula, but this loop will depend by the precision that the user wants.

Finally, you need to truncate the number calculated depending by the precision asked.

Here you can see my code and the program working.

If you don’t know how to round a float, you can check this page: http://stackoverflow.com/questions/11208971/round-a-float-to-a-given-precision/11209099#11209099

Also, here you can find my code:

GitHub: https://github.com/taniaprogram/SolvingProblemsWithProgramming/blob/master/Euler.cpp

Google Drive: https://drive.google.com/file/d/0B-NM4ghaDXBvUEw5RE9nTVZrTjQ/view?usp=sharing

CC BY 4.0 #WSQ14 by Tania Pardo is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.