Control the Flow

The use of the three basic programming constructs used to control the flow of a program:

  • Sequence – the order in which things happen
  • Selection – choosing between possible actions
  • Iteration – repeating actions

The three above constructs are dependant on conditional and logical operators.

Meaning Symbol
Greater than
>
Less than
<
Greater than or equal to
>=
Less than or equal to
<=
Not equal to
!=
Equal to (Are the same, careful not to confuse with assignment operator)
==

Selection: Conditionals

 

The most basic conditional statement is IF. In pseudocode, you will see IF statements written like this:

                  IF (expression) THEN
                      ... Do this
                  END IF

Example pseudocode

                   YourAge = input("Enter your age in years")

                   IF YourAge <= 16 THEN
                        PRINT 'You are still attending school'
                   END IF

The first line is asking the user to enter their age.

The IF uses the expression YourAge <= 16 to determine if the PRINT statement should be run or not. i.e. if 16 years old or younger then the expression is true and the print statement is carried out.

Once you translate the pseudocode into actual source code, the formatting of IF statements will depend on the exact syntax of the language you are using. But the way they they are used remains the same.

Python Example

 

 

 

Scroll to Top