Lines 5-7: You're ignoring what I pointed out about z[] going out of scope. At line 7, z[] and ptr are NO LONGER VALID.
Line 16: You're trying to use interest for two different things. The interest rate and the amount of interest accrued. Not a good idea. This is why I introduced rate in the sample I posted.
Line 1: c (credit) is passed by reference. If you were to update c within values(), the change would be reflected in the caller (main). Same goes for interest (it).
AAAAAAA i get it now sorry for that :D but how would you do it in your post u just return one value let's forget about the example i posted think about any other situation where you have to send two variables or results to main how would you do that?
As I mentioned before, you're still using interest for two different purposes. Not a good idea.
Suppose you want to call changed_values() a second time. interest no longer has the original rate in it. As I suggested before, rate should be a const value.
constdouble rate = 10.0;
.
This means of course you're going to need either make rate a global, or pass a third argument to changed_values.
I get it and when i need interest again the variable is changed , but it was only a random name and random purpose :D but i know what u talking in programming u need to consider everything :D