The ‘while’ loop

2/4/99


Click here to start


Table of Contents

The ‘while’ loop

A Repetitive Structure - The while Loop

Our example while loop

Another while loop example

The pseudo-code

Class Grade Average for 10 Students

Versatile ?

A better algorithm Grade Average for N Students

Grade Average for N students

Why bother to make it easier ?

Using a Sentinel Value

The Priming Read

Pseudo-code for Using a Sentinel to End a while Loop’s Execution

Using a Sentinel to End a while Loop

Using a Sentinel (continued)

The cast operator ( )

What Happens When We Cast ?

Using a while Loop to Check User Input

Author: Sue Bogar

Email: frey@cs.umbc.edu