My coding on computer shows right answer but on codechef it gives wrong ans

help
c-plus-plus
codechef
correct-output
error
newbie
wrong-answer

#1

http://www.codechef.com/problems/COINS for this question i have written a code
http://www.codechef.com/viewsolution/6885244 . Kindly let me know what is wrong with my code . I am a newbie and
I am coding in C++ 4.3.2
what is wrong with my code ???


#2

Declare y and z outside do while loop,otherwise they are getting repeatedly declared.
Logic is correct .
return sum only if sum>x(or y or z)
otherwise it wont give correct answer
Try for input 11 24 13 25 16
ans should be 11 27 13 25 17