January 2014
Intermediate to advanced
736 pages
70h 43m
English
Compare the program logic for sentinel-controlled repetition in this application with that for counter-controlled repetition in Fig. C.2. In counter-controlled repetition, each iteration of the while statement (e.g., lines 52–58 of Fig. C.2) reads a value from the user, for the specified number of iterations. In sentinel-controlled repetition, the program reads the first value (lines 53–54 of Fig. C.5) before reaching the while. This value determines whether the program’s flow of control should enter the body of the while. If the condition of the while is false, the user entered the sentinel value, so the body of the while does not execute (i.e., no grades were ...
Read now
Unlock full access