CIS 1057 Chapter Notes - Chapter 7: Infinite Loop, Function Prototype
Document Summary
Conditional loops repeat until a desired condition is met. E. g. until a proper input is given. Placing loop processing in a function subprogram simplifies the main function. It is good practice to leave a comment above a loop detailing its purpose. Sentinel values are end markers that follow the last item in a list of data. Sentinel-controlled loops repeat and test data until a sentinel value occurs, which causes the loop to exit. A sentinel loop can be implemented in both a for and while statement. Iterates through data until an endfile character has been reached. If a while loop encounters faulty data, it can become an infinite loop, as the complement to the loop repetition condition will never be met. As other control structures, loops can be placed within another to form nested loops. With each repetition of the outer loop, the inner loop is reentered and their loop control variable is reevaluated.