SajithaPathirana1
186 views
11 slides
Nov 16, 2022
Slide 1 of 11
1
2
3
4
5
6
7
8
9
10
11
About This Presentation
GCSE Lesson - Pseudocode
Size: 228.58 KB
Language: en
Added: Nov 16, 2022
Slides: 11 pages
Slide Content
Pseudocode
What is Pseudocode ? An informal way of writing a program High level description Text base Algorithmic
Common pseudocode notation INPUT – indicates a user will be inputting something OUTPUT – indicates that an output will appear on the screen WHILE – a loop (iteration that has a condition at the beginning) FOR – a counting loop (iteration) REPEAT – UNTIL – a loop (iteration) that has a condition at the end IF – THEN – ELSE – a decision (selection) in which a choice is made any instructions that occur inside a selection or iteration are usually indented
Mainly Three Processes Sequence Iteration Selection In the Order they need to happen Conditional statements
Sequence Summation of two numbers Input number1 Input number2 Total= number1+number2 Output total
Selection Two types of Selection Processes IF ... THEN ... ELSE ... CASE STATEMENT (SWITCH) Mainly used to process between two options Can compare more than two with multiple IF ELSEs Also can use as nested statements Mainly used to process between more than two options
IF ... THEN ... ELSE ... IF x>=1 then Print “x is positive”; ELSE IF x==0 then Print “x is 0” ELSE IF x<0 then Print “x is negative” END IF
If isDigit (x) then If x==0 then Print “x is o” Else if x>0 then Print “x is positive” Else Print “x is a character” Nested If Statements
Case Statement (Switch) CASE x OF 1: Do this thing 2: Do the other thing 3: Self-destruct ELSE Write “You must choose 1, 2 or 3” END CASE
Iteration Three types of Iteration Processes For loop Repeat Until While FOR count = 1 to 10 DO Write count x 3 NEXT count count = 1 REPEAT Write count x 3 count = count + 1 UNTIL count = 10 WHILE not eof ( StudentFile ) DO Read ( StudentFile ) Write surname,firstname,grade END WHILE