Jump to content


Photo

Loops In Sharpen Your Pencil - Exercise, Page115

Loops sharpen your pemcil page115 Ch 2

  • Please log in to reply
2 replies to this topic

#1 KNut

KNut

    New Member

  • Members
  • Pip
  • 2 posts
  • Gender:Male

Posted 19 August 2015 - 10:32 PM

Hello everyone! Cant understand, how code works in Loop #3 and Loop #5 in chapter 2, page 79 (not 115)! smile.png Please help me!
Here's scan for easy going!

Attached Thumbnails

  • 1.PNG

Edited by KNut, 19 August 2015 - 10:47 PM.


#2 AndrewStellman

AndrewStellman

    Andrew Stellman

  • O'Reilly Author
  • PipPipPipPipPipPipPipPipPipPipPip
  • 832 posts
  • Gender:Male
  • Location:Brooklyn, NY
  • Interests:Author of: "Head First C#", "Beautiful Teams", "Head First PMP", "Applied Software Project Management"

Posted 20 August 2015 - 09:36 AM

Here's a good explanation for loop #5 that was posted a few years ago: http://forums.oreill...-loop-5-pag-71/

 

For loop #3, the easiest way to understand it is to place a breakpoint on the "j = j - 1;" statement (just like you did on page 70) and see how many times it breaks. Then add a watch for the j variable and another watch for the i variable (again, like you did on page 70) and step through it line by line to see how the i and j variables change.

 

I hope this helps!


Andrew Stellman
Author, Head First C#
Building Better Software -- http://www.stellman-greene.com

#3 KNut

KNut

    New Member

  • Members
  • Pip
  • 2 posts
  • Gender:Male

Posted 26 August 2015 - 11:10 PM

Didn't expect, that the author will be the one who will answer, that really great! Much thanks for advice! Thinks it will!







Also tagged with one or more of these keywords: Loops, sharpen your pemcil, page115, Ch 2

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users