Pseudo-code for Using a Sentinel to End a while Loop’s Execution
Initialize total to 0
Initialize counter to 0
Get the first grade from the user
While the grade != the sentinel value
Add grade to total
Add 1 to counter
Get the next grade (could be sentinel)
end_while
average = total / counter
Print the average
Previous slide
Next slide
Back to first slide
View graphic version