Ddoocp Topic 4
Ddoocp Topic 4
Programmes
Topic 4: Programming Structures (2)
Learning Outcomes
Repetition Structures - 1
• In the last topic we looked at the power of selection
structures to shape the flow of execution through a
program.
• These permit us branches that we can follow, or
not, to have the program respond to the information
it has at run-time.
Title of Topic Topic 1 - 1.5
Repetition Structures - 2
• We often don’t know at design time what the state
of individual variables in a program might be and so
we make use of these structures to handle
uncertainty.
• However, often we don’t want to simply choose
between two or more course of action – sometimes
we want to repeat the same course of action
several times.
• This is where iteration enters the picture.
Title of Topic Topic 1 - 1.6
Conclusion - 1
• Loops have just put a lot of additional power into
your hands – structurally they are similar to the
selections we looked at in the previous chapter, but
provide additional opportunities for seriously
impacting on the flow of your project.
• As you can see in the example above, they can
even be placed inside each other – you can have if
statements inside a for statement, for statements
within a while loop, and any combination besides.
Title of Topic Topic 1 - 1.29
Conclusion - 2
• This is called nesting and we’ll have cause to see
lots of examples of this as time goes by.
• In the meantime, mastering loops is going to offer
you a much greater opportunity to create
meaningfully interesting projects – that’s especially
true when we come to look at arrays in a couple of
chapters’ time.
Topic 4 – Programming Structures (2)
Any Questions?