1 / 14

Sequence

Sequence. Damian Gordon. 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. Pseudocode.

mreese
Télécharger la présentation

Sequence

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Sequence Damian Gordon

  2. 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.

  3. 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.

  4. Pseudocode • In Pseudo code it looks like this: Statement1; Statement2; Statement3; Statement4; Statement5; Statement6; Statement7; Statement8;

  5. 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;

  6. 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.

  7. 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.

  8. 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

  9. START 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 END

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

  11. Pseudocode PROGRAMPrintNumber: Read number; Print out number; END.

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

  13. Pseudocode PROGRAMPrintDoubleNumber: Read number; Print 2 * number; END.

  14. etc.

More Related