#logic #programming #KK8 [[Outcome 1 - Programming#8. features of a programming language, including| U3 - AOS1 - KK8]] # Sequence ![[images.png]] Sequence means putting your instructions in the right order so a computer can follow them correctly. Just like following a recipe, if the steps aren’t in the proper order, the whole thing falls apart. Think of making a peanut butter and jelly sandwich: you wouldn’t spread the jelly before getting out the bread. A computer is the same—it needs each step in the right place, or the end result won’t work the way you want it to. # Selection ![[Pasted image 20251118110213.jpeg|250]] The basic attribute of a selection control structure is to be able to select between two or more alternate paths. A question using [[Data Types#Boolean|boolean]] concepts usually controls which path is selected. All of the paths from a selection control structure join back up at the end of the control structure, before moving on to the next lines of code in a program. ### If Then Else Control Structure The **if then else** control structure is a two-way selection. ``` IF age > 17 then Output " You can vote" Else then Output "You can't vote" End IF ``` ![[Pasted image 20251118110641.jpeg|250]] # Iteration / Repetition *Iteration statements,* commonly known as [loops](https://www.geeksforgeeks.org/dsa/loops-programming/), are statements in programming used to execute part of code repeatedly based on condition or set of conditions. These constructs are important for performing repetitive tasks efficiently. In this article, we will discuss various types of iteration statements and their use in different programming languages. ## Types of Iteration Statements in programming: There are mainly three types of iteration statements: [[For Loop]] [[While Loop]] [[Do While]] ### 1. For Loop: For loops iterate over a range of values or elements in a collection. These are mainly used where the number of iterations is known beforehand like iterating through elements in an array or predefined range. ``` FOR i In Range(5): print(i) ``` ### 2. While Loops While loops execute as long as specifies condition evaluates to true. These are suitable for situations where the number of iterations is not known and depends on dynamic conditions. ``` SET count = 0 WHILE count < 5: print(count) count += 1 ``` ### 3. Do-While Loops Do while loops are similar to while loop but guarantee at least one execution of the loop body before checking the condition. These are useful when loop must execute at least once regardless of the condition. ``` SET count = 0 DO print(count) count += 1 WHILE (count < 5) ``` # Exam Question ![[2023 Exam#Question 3]] ![[2025 Exam#**Use the following information to answer question 4 and 5**]] ![[2025 Exam#**Question 4**]]