English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

How does a sentinel value differ from a program flag as a means of loop control?

For a sentinel value to be used properly when reading in data, how many input statements should there be and where should the input statements appear?

Please i need help with these two questions, these are the last two i need!! cant seem to figure it out...

2007-03-02 06:01:40 · 1 answers · asked by Anonymous in Computers & Internet Programming & Design

1 answers

a sentinel value is used to make search easier for instance. Because you know that you'll find that value in a array. A program flag is something that indicates if an operation was correctly made or not.
Many inputs can be made if you are using a sentinel value. Only when the user input the sentinel value that the resquesting for more values will end and the process of the program will continue. Notice that the sentinel value must not be a valid value so if you have an array of positive integers -1 would be a good sentinel value because the user can not use it as a valid input. The same happens to a string which the sentinel could be END as long as this is not a valid input for your program.

2007-03-03 05:03:23 · answer #1 · answered by Anonymous · 0 0

fedest.com, questions and answers