CUW CSC 250 - The Repetition Control Structure 1 (21 pages)

Previewing pages 1, 2, 20, 21 of 21 page document View the full content.
View Full Document

The Repetition Control Structure 1



Previewing pages 1, 2, 20, 21 of actual document.

View the full content.
View Full Document
View Full Document

The Repetition Control Structure 1

31 views

Other


Pages:
21
School:
Concordia University Wisconsin
Course:
Csc 250 - Computer Science Theory and Practice I
Computer Science Theory and Practice I Documents

Unformatted text preview:

The Repetition Control Structure 1 0 Announcements 1 Intro to loops 2 Types of loops 3 Design considerations 0 Announcements Take in Assignment 3 Any questions on hw 3 due Thursday Please send me an e copy of your assignment as an email attachment file H O and explain Assignment 4 1 Introduction to loops A What Loops are a means of implementing the repetition iterative control structure Allows one or more statements to be executed repeatedly until a terminating condition is reached Cooking analogy Bake for 30 minutes Or Bake until golden brown Introduction to loops cont B What does a loop consist of 2 parts A the loop body a set of 1 or more statements to be repeated B the loop condition a condition that determines when the loop body is entered and exited Introduction to loops cont C What are the 2 main forms of loops Pre test and Post test loops Meaning 1 In a pre test loop we test the loop condition before entering the loop body If the condition is true we enter if it is false we exit See flow chart and C example Introduction to loops cont 2 In a post test loop we enter the loop body then test the loop condition If the condition is true we re enter the loop body if it is false we exit the loop body See flow chart and C example Comparison of Pre Post test loops Pre test 1 Loop entered 2 Loop is executed times 3 Best to use if Post test 1 Loop entered 2 Loop is executed times 3 Best to use if Introduction to loops cont Pre test loops are good if it is possible the loop will not run at all but can be skipped E g while Brewers Wins 1 More seriously if the user is given a quit option they may choose it immediately because they are not interested in any of the options 2 Types of loops Regardless of their form pre test or posttest there are several types of loops These types are distinguished by what controls the loop In most cases this is the value of a special variable called how imaginative the Loop Control Variable or LCV Types of loops continued There is a division



View Full Document

Access the best Study Guides, Lecture Notes and Practice Exams

Loading Unlocking...
Login

Join to view The Repetition Control Structure 1 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view The Repetition Control Structure 1 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?