MOD6 - Repetition Structures (Loops)

Objectives:

The Looping Structure is going to help you give repetition to your program. You will be able to repeat areas of code and start the development of complex solutions. Let's see what we can build.

Quick Check Link

This section is usually around Chapter 5 in popular textbooks. Take a look at the Quick Check Link to see if you need to spend extra time here.

As you advance your training you need to check to make sure you are ready to move on. You just might want to make the next link connection to take a Pre-test and see if you are ready for our subject. If it goes well you might take the Post-test to see if you are advanced. While you are here you could also look for any solution demonstrations.

(click here for Quick Check Link)

Vocabulary Critical

Looping Vocabulary for most Textbooks

condition

while loop

for loop

do until loop

pretest

infinite loop

counter loop

iterations

increment

decrement

accumulator

sentinel value

variable

input

terminal symbol

posttest

flag

end while

end for

++ operator

-- operator

 

Introduction to Loops 

One of the most important things you can do with your computer is to repeat an action. We have several ways to describe this process.

Let's talk about a few of the highlights:

  • Somtimes this is called "repitition"
  • Somtimes it is called a "loop"
  • It is one of the three basic structures for programming
  • Parts needed for this technique
    • You must identify a start location
    • You will need a condition (beginning/ending)
    • You will need commands to perform
    • You will need an exit point

Look over your study text and become familiar with the terminology. Then you will be ready to attempt a couple of exercises.

 

Exercise #1 (Bug Collector)

If you are using the text from Tony Gaddis then you can follow along with me (Chapter 5 Programming Exercise #1). You might even want to attempt this exercise before you look at my solution.

Now I'm going to solve the Bug Collector project with the help of our author's video note. Try to watch and see if you can get the same solution I do. I will follow the Gaddis example and use Raptor to give me a runable flowchart.

Carter's Video Solution: Part 1

alternative accessible content

Carter's Video Solution: Part 2

alternative accessible content

Carter's Video Solution: Part 3

alternative accessible content

 

Exercise #2 (Sum of Numbers)

Now let's complete one from scratch. This one is also from the Tony Gaddis chapter on Repition (Chapter 5 Programming Exercise #4).

1) Look over the project.

2) You may want to stop here and see if you can come up with a solution on your own.

3) Setup your version of a Program Analysis Worksheet

4) Solve the problem using Raptor or you might use Flowgorithm

The solution for this project will be included in the Quick Check Link for MOD6. Scroll to the top of this page for a link.

Feedback for MOD6

I really appreciate feedback from people who use my site. Each time you complete a subject from the top it would be great if you could send me feedback. Just email me to say what you like, what you dislike and any corrections you might suggest. You could also let me know if you had your own solution to suggest. My email is (objectcoach@aol.com).