成人快手

Programming constructs - EduqasNesting

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.

Part of Computer ScienceSystems analysis

Nesting

and constructs can be within each other. Any combination of selection and iteration is possible. So, for example, a for next 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 鈥淗ow old are you?鈥, age
                if age >= 16
                    output 鈥淵ou are old enough to drive a moped!鈥
                    if age >= 17
                    output 鈥淵ou are old enough to drive a car!鈥
                    聽聽聽聽end if
                else
                    output 鈥淐ome back when you are older!鈥
                end if