sequence damian gordon. pseudocode when we write programs, we assume that the computer executes the...

14
Sequence Damian Gordon

Upload: myra-curtis

Post on 20-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Sequence Damian Gordon. Pseudocode When we write programs, we assume that the computer executes the program starting at the beginning and working its

SequenceDamian Gordon

Page 2: Sequence Damian Gordon. Pseudocode When we write programs, we assume that the computer executes the program starting at the beginning and working its

Pseudocode

• When we write programs, we assume that the computer executes the program starting at the beginning and working its way to the end.

• This is a basic assumption of all algorithm design.

Page 3: Sequence Damian Gordon. Pseudocode When we write programs, we assume that the computer executes the program starting at the beginning and working its

Pseudocode

• When we write programs, we assume that the computer executes the program starting at the beginning and working its way to the end.

• This is a basic assumption of all algorithm design.• We call this SEQUENCE.

Page 4: Sequence Damian Gordon. Pseudocode When we write programs, we assume that the computer executes the program starting at the beginning and working its

Pseudocode

• In Pseudo code it looks like this:

Statement1;Statement2;Statement3;Statement4;Statement5;Statement6;Statement7;Statement8;

Page 5: Sequence Damian Gordon. Pseudocode When we write programs, we assume that the computer executes the program starting at the beginning and working its

Pseudocode• For example, for making a cup of tea:

Organise everything together;Plug in kettle;Put teabag in cup;Put water into kettle;Wait for kettle to boil;Add water to cup;Remove teabag with spoon/fork;Add milk and/or sugar;Serve;

Page 6: Sequence Damian Gordon. Pseudocode When we write programs, we assume that the computer executes the program starting at the beginning and working its

Pseudocode• Or as a program:

PROGRAM MakeACupOfTea: Organise everything together; Plug in kettle; Put teabag in cup; Put water into kettle; Wait for kettle to boil; Add water to cup; Remove teabag with spoon/fork; Add milk and/or sugar; Serve;END.

Page 7: Sequence Damian Gordon. Pseudocode When we write programs, we assume that the computer executes the program starting at the beginning and working its

Pseudocode• Or as a program:

PROGRAM MakeACupOfTea: Organise everything together; Plug in kettle; Put teabag in cup; Put water into kettle; Wait for kettle to boil; Add water to cup; Remove teabag with spoon/fork; Add milk and/or sugar; Serve;END.

Page 8: Sequence Damian Gordon. Pseudocode When we write programs, we assume that the computer executes the program starting at the beginning and working its

Organise everything together

Plug in kettle

Put teabag in cup

Put water into kettle

Turn on kettle

Wait for kettle to boil

Add boiling water to cup

Remove teabag with spoon/fork

Add milk and/or sugar

Serve

Page 9: Sequence Damian Gordon. Pseudocode When we write programs, we assume that the computer executes the program starting at the beginning and working its

Organise everything together

Plug in kettle

Put teabag in cup

Put water into kettle

Turn on kettle

Wait for kettle to boil

Add boiling water to cup

Remove teabag with spoon/fork

Add milk and/or sugar

Serve

START

END

Page 10: Sequence Damian Gordon. Pseudocode When we write programs, we assume that the computer executes the program starting at the beginning and working its

Pseudocode

• So let’s say we want to express the following algorithm:– Read in a number and print it out.

Page 11: Sequence Damian Gordon. Pseudocode When we write programs, we assume that the computer executes the program starting at the beginning and working its

Pseudocode

PROGRAM PrintNumber: Read number; Print out number;END.

Page 12: Sequence Damian Gordon. Pseudocode When we write programs, we assume that the computer executes the program starting at the beginning and working its

Pseudocode

• So let’s say we want to express the following algorithm:– Read in a number and print it out double the number.

Page 13: Sequence Damian Gordon. Pseudocode When we write programs, we assume that the computer executes the program starting at the beginning and working its

Pseudocode

PROGRAM PrintDoubleNumber: Read number; Print 2 * number;END.

Page 14: Sequence Damian Gordon. Pseudocode When we write programs, we assume that the computer executes the program starting at the beginning and working its

etc.