Dissecting Pseudocode

Pseudocode
1 / 56
next
Slide 1: Slide
ICTSecondary Education

This lesson contains 56 slides, with interactive quizzes, text slides and 1 video.

Items in this lesson

Pseudocode

Slide 1 - Slide

Objective
  1. To be familiar with the data types in pseudocode.
  2. To revise the function of Sequence
  3. To write a Sequence pseudocode

Slide 2 - Slide

Data Types in Pseudocode

Slide 3 - Slide

String
The String data type is used for data that can be used to store a number of letters, digits and symbols.

"...."

Slide 4 - Slide

String
When assigning data to a string it should be placed within quotes e.g. name = "Dave"

Slide 5 - Slide

Strings
Strings are printable, Mathematical operations cannot be performed on strings even if they only contain numbers.

e.g. if you have the following code:

x = "7" 
y = "3"
OUTPUT x + y

The result that is output for the user would be "73" NOT 10. This is known as concatenation, 2 or more strings can be joined together using the + symbol.

Slide 6 - Slide

Integer
An Integer can be used to store a positive whole number (No decimals numbers)

You'll see this in Exams as Int

Slide 7 - Slide

REAL
The Real data type will allow you to store decimal numbers (Positive or negative) e.g. Cost = 5.50

​Real data can be used in mathematical operations

Slide 8 - Slide

CHAR
The Char data type can be used to store one single character.

​e.g. Gender = "M"

Slide 9 - Slide

BOOLEAN
The Boolean data type can have only two possible values, these are TRUE or FALSE.

​E.g. Accepted = true

Slide 10 - Slide

Any questions on Data Types for Pseudocode?

Slide 11 - Open question

Sequence

Slide 12 - Slide

Sequence refers to
A
code or sections of code that run line by line, in sequential order without deviation.
B
code that repeats a certain number of times.

Slide 13 - Quiz

Question 1
Write a SEQUENCE pseudocode to instruct a user to input their age and name.

Make sure to use OUTPUT,INPUT, and don't forget to use "..." for sentences

Slide 14 - Slide

SEQUENCE Syntax Instructions in IGCSE
INPUT - prompting your user to put in text or numbers. 

"..." - Strings marks or quotation marks is to indicate the TEXT ONLY sentences in your pseudocode.

OUTPUT/PRINT - To display or show the outcome instructions.

Slide 15 - Slide

Write a SEQUENCE pseudocode to instruct a user to input their age and name.

Make sure to use OUTPUT,INPUT, and don't forget to use "..." for sentences

Slide 16 - Open question

Objective
  1. To be familiar with the data types in pseudocode.
  2. To revise the function of Sequence
  3. To write a Sequence pseudocode

Slide 17 - Slide

Objective
  1. To revise the function of Selection
  2. To write a IF pseudocode
  3. To write a CASE pseudocode

Slide 18 - Slide

In programming, the term selection means
A
that the program can choose to run different commands based on a condition being true or false.
B
follows a set of instructions that with the order it is given.
C
code that repeats a certain number of times.

Slide 19 - Quiz

Write a pseudocode to instruct a user to input their age and name. If then person is older than 18 then your pseudocode should allow the person input their address and telephone number, else you have to let them know they are too young to drive.

Slide 20 - Open question

Slide 21 - Slide

IF and Case - Selection

Slide 22 - Slide

Slide 23 - Slide

Slide 24 - Slide

Slide 25 - Slide

Create a CASE pseudocode that shows 3 different fruits and their pricing. Output an error message if the user did not select 3 of the options.

Slide 26 - Open question

Slide 27 - Slide

Theory Questions

Slide 28 - Slide

Explain the difference between the programming concepts of sequence and selection.

Include an example of a programming statement for each concept in your explanation (4m)

Slide 29 - Open question

Objectives
1.  To revise on the function of IF statement.
2. To practice on the function of CASE statement.
3. To distinguish the function between Sequence and Selection.

Slide 30 - Slide

Objectives
1.  To revise on Selection.
2. To define Iteration 
3. To practise writing FOR...TO...NEXT

Slide 31 - Slide

A programmer wants to test that the readings from 2000 electricity meters are greater than 400 units and less than 900 units.

Explain, using programming statements, how selection could be used n this program. (2m)

Slide 32 - Open question

IF... THEN... ELSE... ENDIF is one type of conditional statement used when writing pseudocode

Identify and describe another type of conditional statement that you could use when writing pseudocode. Give a reason why you would use this type of conditional statement.

(4M)

Slide 33 - Open question

Objectives
1. To revise on Iteration
2. To define Iteration 
3. To practise writing FOR...TO...NEXT

Slide 34 - Slide

Iteration means
A
that the program can choose to run different commands based on a condition being true or false.
B
it does nothing
C
to repeat something over and over like a loop
D
follows a sequence order

Slide 35 - Quiz

Slide 36 - Slide

Slide 37 - Slide

Types of Iteration
For loop
While loop
Repeat until loop

Slide 38 - Slide

For loop is used when
A
code needs to be repeated a specified number of times
B
will repeat forever while a set condition is true. also known as pre-condition loops.
C
will repeat forever UNTIL a condition becomes true. also known as a Post-condition loop.

Slide 39 - Quiz

Slide 40 - Slide

Objective
1. Revise on Iteration
2. Practise a few iteration questions

Slide 41 - Slide

Bob opens his business for 7 days. Create a For loop to calculate the total money made for the 7 days.

Slide 42 - Open question

WHILE LOOPS
While loops are also known as pre-condition loops. This is because a while loop will repeat forever WHILE a set condition is true. This condition is checked at the start of the loop hence the name "pre-condition".

Slide 43 - Slide

While loops are particularly useful when you do not know specifically how many times you want the code to repeat.

Slide 44 - Slide

Example Uses
  • A user should be able to use a program as many times as they like until they choose to quit
  • A dice game will allow the user to roll the dice until they choose to quit
  • A program should repeat forever (No way for the condition to be false)
  • Validating a user input e.g. not accepting a password if it is less than 8 characters long.

Slide 45 - Slide

REPEAT UNTIL LOOPS
A REPEAT UNTIL loop is also known as a Post-condition loop. This type of loop will repeat forever UNTIL a condition becomes true.

Slide 46 - Slide

REPEAT...UNTIL is one type of loop structure.

Identify and describe TWO other types of loop structure that you could use when writing pseudocode.

What are the two loop structures? Describe them.

Slide 47 - Open question

Objective
  1. Revise on Iteration
  2. Practice on For Loops
  3. Practice on While Loops
  4. Practive on Repeat Loops

Slide 48 - Slide

Describe the purpose of each statement in this algorithm.

For X <- 1 TO 300
INPUT NAME
NEXT X

Slide 49 - Open question

Explanation
The instructions requires 300 loops to input Names at each round.

Slide 50 - Slide

Create a loop, that Input 10 numbers and print out their total

Slide 51 - Open question

Slide 52 - Video

Input some numbers and calculate their total, stop when the total is greater than 20.

Slide 53 - Open question

An algorithm has been written in pseudocode to input 100 numbers and print out the sum. A REPEAT...UNTIL lopp has been used.

Slide 54 - Slide

Find the error in the pseudocode and suggest a correction

Slide 55 - Open question

Rewrite the correct algorithm using a more suitable loop structure.

Slide 56 - Open question