§‡‡‡Quiz4‡‡‡§

Photograph credit

zxsq3

Hey guys, IT WORKS, but it isn’t perfect. I had a problem and I got around it but it isn’t fixed. The problem I had was this: Basically the user inputs a number like 0.00001 and my loop is supposed to multiply it by 10 until it reaches 1. Once that value reaches 1 then the loop is supposed to stop and tell me how many times the loop was run. The problem is that the value NEVER equals 1. I don’t know why that happens. If you guys know how to fix this, please help. Here is my code: with the loop that has the problem, the orginal and the one that prints out each value(so you can see what is going on with e):

LoopFunction.cpp

euler_calc.cpp

Quiz4.cpp

Screen Shot 2016-02-27 at 2.53.27 PM

This function tells me how many significant figures will be used to print out euler’s number.

Screen Shot 2016-02-27 at 3.08.35 PM.png This function simply gets the factorial of a number.

Screen Shot 2016-02-27 at 3.10.22 PM.png

With this function I calculate the value e, in my loop you will notice that my conditional is pre>x. well x is the number given by the user to know how many significant figures to use for e. pre is the difference between the previuos and the actual value of e. so if x=0.0001 then the loop will continue until pre(the difference of the previous and actual value of e) is less than 0.0001.

You will probably notice that I have a command that says set precision(26). This just makes the program print out the number with that many significant figures.  I look here
for that command.