Definition: Sequencing is the order in which steps are executed in a program. Code runs from top to bottom.
Key Ideas:
Example:
x = 5 y = x + 3 DISPLAY(y)
Why Sequencing Matters:
Definition: Selection uses conditions to control which block of code runs, using if-statements.
Key Ideas:
Example:
IF(score > 70)
DISPLAY("You passed!")
ELSE
DISPLAY("Try again.")
END
Common Uses:
Definition: Iteration repeats a block of code multiple times using loops.
Types of Loops:
Examples:
Repeat N Times Loop:
REPEAT 5 TIMES
DISPLAY("Hello")
END
Repeat Until Condition:
REPEAT UNTIL(answer == "yes")
answer = INPUT()
END
Key Concepts:
Definition: Nesting means placing one control structure inside another.
Why Nesting Matters:
Example:
REPEAT UNTIL(gameOver)
IF(score > highScore)
DISPLAY("New High Score!")
END
END
Nested Loops Example:
FOR row FROM 1 TO 5
FOR column FROM 1 TO 5
DISPLAY(row, column)
END
END
Programs combine sequencing, selection, and iteration to create functional algorithms.
Example: Guessing Game Logic
secret = RANDOM(1,10)
guess = 0
REPEAT UNTIL(guess == secret)
guess = INPUT("Enter a number")
IF(guess < secret)
DISPLAY("Too low")
ELSE IF(guess > secret)
DISPLAY("Too high")
ELSE
DISPLAY("Correct!")
END
END
This example uses: