CMPT 120 Lecture 14: Part 2: Introduction to Loops - Repetition Structures - while
meghan78 and 39786 others unlocked
29
CMPT 120 Full Course Notes
Verified Note
29 documents
Document Summary
Lecture 14 part 2: introduction to loops: repetition structures - while. Sentinel: special value used to mark end of a sequence of items or loop. When program reaches a sentinel, it knows that the end of the sequence of items was reached, and the loop terminates. Must be distinctive enough so as not to be mistaken for a regular value in the sequence. Computer cannot tell the difference between good data and bad data. If user provides bad input, program will produce bad output. It is important to design program such that bad input is never accepted. Input validation: inspecting input before it is processed by the program. If input is invalid, prompt user to enter correct data. Commonly accomplished using a while loop which repeats as long as the input is bad. If input is bad, display error message and receive another set of data.