CMPT 120 Lecture 14: Part 2: Introduction to Loops - Repetition Structures - while

35 views2 pages
meghan78 and 39786 others unlocked
CMPT 120 Full Course Notes
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.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents