I am trying to calculate the silver ratio via a recurrence relation but when i run the code i just get incorrect values for all but the first 3 values.
The problem is that you're declaring lfloat and ldouble inside the loop. That means that each iteration creates new lfloat and ldouble variables. As a result, when you compute the new values at lines 41 and 42, float.at(i-1) is zero.
Just move lines 21 and 22 above line 18
BTW, you don't need to write the data to cout and silver.txt. Just write it to cout. When the program is running correctly, enter "prog > silver.txt" to send cout to silver.txt. Be sure to remove line 53 since it won't be needed.