Programs are created using common building blocks, known as programming constructs. These programming constructs form the basis for all programs and are also used in algorithms.
selectionA decision within a computer program when the program decides to move on based on the results of an event. and iterationThe repetition of a block of statements within a computer program. constructs can be nestingIncluding one programming construct within another. within each other. Any combination of selection and iteration is possible. So, for example, a for nextloopThe repetition of an activity within a computer program. might have an if … else … end if selection within it.
This example has an if … else … end if construct nested within another if … else … end if construct:
age is integer input “How old are you?”, age if age >= 16 output “You are old enough to drive a moped!” if age >= 17 output “You are old enough to drive a car!” end if else output “Come back when you are older!” end if