COMPUTER SCIENCE             YEAR 8
SUBJECT:     COMPUTER SCIENCE
TERM:           SUMMER
CLASS:          YEAR 8
SCHOOL:         SQUARE COLLEGE
SESSION:       2023/2024
                 TEACHER: MRS MARK
ALGORITHM AND DATA 1 & 2
ALGORITHM, PSEUDOCODE, FLOWCHART
            Mrs Mark
What is an algorithm?
An algorithm is a plan, a set of step-by-step instructions to solve a
problem. In an algorithm, each instruction is identified and the order in
which they should be carried out is planned. Algorithms are often
used as a starting point for creating a computer program
Representing an algorithm: Pseudocode
There are two main ways that algorithms can be represented –
pseudocode and flowcharts.
Most programs are developed using programming languages.
These languages have specific syntax that must be used so that the
program will run properly. Pseudocode is not a programming
language, it is a simple way of describing a set of instructions that
does not have to use specific syntax.        Mrs. Mark
Writing in pseudocode is similar to writing in a programming language.
Each step of the algorithm is written on a line of its own in sequence.
Usually, instructions are written in uppercase, variables in lowercase
and messages in sentence case. In pseudocode, INPUT asks a
question. OUTPUT prints a message on screen.
A simple program could be created
to ask someone their name and age,        OUTPUT 'What is your name?'
and to make a comment based on            INPUT user inputs their name
                                          STORE the user's input in the name variable
these. This program represented in        OUTPUT 'Hello' + name
pseudocode would look like this:          OUTPUT 'How old are you?'
                                          INPUT user inputs their age
                                          STORE the user's input in the age variable
                                          IF age >= 70 THEN
                                          OUTPUT 'You are aged to perfection!'
                                          ELSE
                              Mrs. Mark   OUTPUT 'You are a spring chicken!'
Representing an algorithm: Flowcharts
A flowchart is a diagram that represents a set of instructions. It can be defined
as pictorial representation of an algorithm.                                    Flowchart symbols
                                         Mrs Mark
 PRINT    PRINT
“PASS”   “FAIL”
                  Mrs Mark
           PRINT
           Lcm
Mrs Mark
           PRINT
              A
Mrs Mark
           Print x1, x2
Mrs Mark
PRINT              PRINT
 A                  B
        Mrs Mark
PRINT      PRINT
 A          B
Mrs Mark
>=
<=
<>
     Mrs Mark
                Print
       “The largest value is”,
                MAX
Mrs. Mark