john pep wrote:Here is the code:
could someone walk through the code with me, and show me where I am exactly going wrong?
Sure; but first, get the indenting right. I don't know if your original source was like it (sometimes books do it on purpose to make the logic more difficult to follow). You can edit your post with the 'Edit' button, and I suspect just doing that may give you a better idea what's going on.
Oh, and use spaces to indent; not TABs.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
I had to resort to some desperate measures, like remembering where I put my copy of HFJ. At least you appear to have copied the code correctly. You are not consistent about the end comments, however. I know a lot of people here don't like end comments, but if you are going to use them at all, they should follow every }.
What you have to do is to go into the loops and write down the values of x and y. Let's try:-...etc, etc
If you get to the print instructions, be careful to work out whether you print the old value of y or the new value.