Unformatted text preview: posCount to 0. We test posCount against ten, and exit the loop when posCount reaches 11. How do we update the event? We increment posCount each time we read a positive value. Many languages have two additional looping structures. We said that the while structure is a pretest loop. Another type of looping structure is one where the testing occurs at the end of the loop. These loops are called posttest loops, for obvious reasons. Posttest loops always execute the loop Set sum to 0 Initialize sum to zero Set posCount to 0 Initialize event While (posCount <= 10) Test event Read a value If (value > 0) Test to see if event should be updated Set posCount to posCount + 1 Update event Set sum to sum + value Add value into sum ... Statement(s) following loop Read a value Initialize event While (value >= o) Test event ... Body of loop Read a value Update event ... Statement(s) following loop...
View Full Document
This note was uploaded on 01/13/2011 for the course CSE 1550 taught by Professor Marianakant during the Fall '10 term at York University.
- Fall '10