REPRESENTING ALGORITHMS II - PSEUDOCODE

3. Control Structures in Pseudocode

Sequence Structure
Simple linear execution of statements:

ALGORITHM SimpleSequence

BEGIN

    READ number1

    READ number2

    sum ← number1 + number2

    PRINT "The sum is: ", sum

END

Selection Structures
Simple IF Statement:

IF condition THEN

    statement(s)

ENDIF

IF-ELSE Statement:

IF condition THEN

    statement(s)

ELSE

    statement(s)

ENDIF

Nested IF Statement:

IF condition1 THEN

    statement(s)

ELSE IF condition2 THEN

    statement(s)

ELSE

    statement(s)

ENDIF

Iteration Structures
WHILE Loop:

WHILE condition DO

    statement(s)

ENDWHILE

FOR Loop:

FOR variable ← start TO end DO

    statement(s)

ENDFOR                   

REPEAT-UNTIL Loop:

REPEAT

    statement(s)

UNTIL condition