You are on page 1of 97

Problem-solving and

design
Computational thinking & problem solving

Computational thinking is a problem-solving process which involves taking a


number of steps to get to the solution as opposed rote learning.

Computational thinking involves abstraction, decomposition, data modelling,


pattern recognition and algorithm design.
Abstraction

Abstraction

Abstraction involves hiding some information which is not necessary to solving


a problem.

Abstraction gives us the power to deal with complexity. An algorithm is an


abstraction of a process that takes inputs, execute-s a sequence of steps, and
produces outputs. An abstract data type defines an abstract set of values and
operations for manipulating those values.
Decomposition

Decomposition involves breaking down a problem into smaller manageable


tasks. The breaking down of tasks makes it easier for us to clearly describe a
process.

Decomposition is another word for stepwise refinement.

Stepwise is the breaking down of an algorithm, task or problem to a level of


(sufficient) detail (into smaller parts / sub-tasks) from which it can be
programmed. The smaller part will be easier to program
Data modelling

Data modelling involves analysing and organising data.

We have used simple data types such as integer, character and Boolean. The
string data type is a composite type:
a sequence of characters. When we have groups of data items we used one-
dimensional (1D) arrays to represent linear lists and two-dimensional (2D)
arrays to represent tables or matrices.
Data modelling

We can set up abstract data types to model real-world concepts, such as


records, queues or stacks. When a programming language does not have such
data types built-in, we can define our own by building them from existing data
types. There are more ways to build data models.

Object-oriented programming can be used build data models by defining


classes. We can model data using facts and rules.
Pattern recognition Pattern
means recognition
looking for patterns or common solutions to
common problems and exploiting these to complete tasks in a more efficient
and effective way.

There are many standard algorithms to solve standard problems, such as


insertion sort or binary search.

Algorithm design
Algorithm design involves developing step-by-step finite set of instructions to
solve a problem

When do you develop algorithms? When: when designing a solution to a


problem.
Why? to describe the solution as a sequence of steps / actions
What is a computer system?
A COMPUTER SYSTEM is made up of software, data, hardware,
communications and people; each computer system can be divided up
into a set of sub-systems.

Each subsystem can be further divided into sub-systems and so on until


each sub-system just performs a single action.
Tools and techniques
A computer system is often divided up into sub-systems.

This division can be shown using top-down design to produce structure


diagrams that demonstrate the modular construction of the system.

Each sub-system can be developed by a programmer as sub-routine or


an existing library routine may be already available for use.
Top-down design
TOP-DOWN DESIGN is the breaking down of a computer system into a
set of subsystems, then breaking each sub-system down into a set of
smaller sub-systems, until each sub-system just performs a single
action.

• This is an effective way of designing a computer system to provide a


solution to a problem, since each part of the problem is broken down
into smaller more manageable problems.
• The process of breaking down into smaller sub-systems is called
‘stepwise refinement’.
Top-down design
Advantages of top down
- When working on a large system many programmers can be assigned
individual modules to work on therefore speeding up the process of
developing and testing the system.
- Individual modules can be tested independently making it easy to
identify and correct errors.
- Easy to expand the system as new modules can be easily added to the
existing system.
- Separate modules can be kept independently and re-used when
needed.
- Allows specialisation as programmers can continue working on
modules related to their area of specialisation.
Top-down design
Q
A program design includes the use of subroutines (functions and procedures).
Give three advantages of using subroutines in a program.

A
• Allows the subroutine code to be called from many/multiple places
• Subroutine code may be (independently) tested and debugged
• If the subroutine task changes the change needs to be made only once
• Reduces unnecessary duplication / program lines
• Enables sharing of development between programmers
Top-down design- Alarm app for a smart phone
• Consider the alarm app computer system for a smart phone. This
could be divided into three sub-systems,
• setting the alarm,
• checking for the alarm time,
• sounding the alarm.
• These sub-systems could then be further sub-divided; the structure
diagram makes the process clearer.
Top-down design- Alarm app for a smart phone
Flow chart
Pseudo code
Algorithms
An algorithm is a sequence of steps which when followed mechanically
will lead to a solution of a problem.
Flowcharts
A FLOWCHART shows diagrammatically the steps required for a task (sub-
system) and the order that they are to be performed. These steps
together with the order are called an ALGORITHM.

Pseudocode
PSEUDOCODE is a simple method of showing an algorithm, using English-
like words and mathematical operators that are set out to look like a
program.
Algorithms
Library routines
A LIBRARY ROUTINE is a set of programming instructions for a given
task that is already available for use. It is pre-tested and usually
performs a task that is frequently required. For example, the task ‘get
time’ in the checking-for-the-alarm time algorithm would probably be
readily available as a library routine.
Sub-routines
A SUB-ROUTINE is a set of programming instructions for a given task that
forms a subsystem, not the whole system. Sub-routines written in high-
level programming languages are called ‘procedures’ or ‘functions’
depending on how they are used.
Algorithms
A TRACE TABLE is used to record the results from each step in an
algorithm; it is used to record the value of an item (variable) each time
that it changes. This manual exercise is called a DRY RUN. A trace table
is set up with a column for each variable and a column for any output.
For example:

Test data is then used to dry run the flowchart and record the results on
the trace table.
• Test data: 9, 7, 3, 12, 6, 4, 15, 2, 8, 5
Structure of an algorithm
An algorithm must always consist of 3 parts
1. Input
The algorithm must take in some form of input for it to work.
Whenever you design an algorithm ensure you have made a provision
for some input to be entered.
2. Process
An algorithm must perform some of calculations, which could be
addition, subtraction, comparisons.
3. Output
An algorithm must produce some form of output, which can be printed
or displayed.
Flow chart symbols
Symbol Description Example

Terminator, denotes the start or end of a flowchart


Start
Input / Output used to denote data input or output. Input/ output will
have 1 entry point and 1 exit
Input Num1, Num2

Decision used to represent a decision in an flowchart. It has one input and


two outputs which could True or False / Yes or No
Num1> Num2?

Process used to denote processing which could be making calculations or


assigning a value to a variable.
Num1 = Num1 + 5

Off page connector, used to link part of a flow chart to the other part on
another page, if it fails to fit on one page
Flow charts
Activity 9.4
• Have a look at the flowchart and pseudocode on the next slide. What
is the purpose of the algorithm that they both represent?

• What would be output if the numbers 7 and 18 were input?


Flow charts
Test data
When testing a program 3 types of test data should be used:
1. Normal data – Normal data is data within the range which should be
accepted by the program. For example if marks range from 0 to
100, normal data would be marks like 3, 87, 45.
2. Extreme data - Extreme data is data on the boundary of acceptance
and should be accepted by the program. For example if marks for a
test range from 0 to 100 then abnormal data will be 0 and 100.
3. Abnormal data – Abnormal data is data outside the given range
which also include illegal keystrokes. Form example if marks range
from 0 to 100, abnormal data would me marks like -4, -40, 101, t,
etc
Stages in producing an algorithm
1 Make sure that the problem is clearly specified.
2 Break the problem down into sub-problems; if it is
complex, you may want to consider writing an
algorithm for each sub-problem. Most problems, even
the simplest ones can be divided into:
• set up (Initialisation of variables)
• input
• processing
• output of results.
Stages in producing an algorithm
• 3 Decide on how any data is to be obtained
and stored, what is going to happen to the
• data and how any results are going to be
displayed.
• 4 Decide on how you are going to construct
your algorithm, using a flowchart or
pseudocode.
Stages in producing an algorithm
• 5 Construct your algorithm, making sure that it
can be easily read and understood by
someone else. This involves setting it out
clearly and using meaningful names for any
data stores.
• 6 Use several sets of test data (normal,
abnormal and boundary) and trace tables to
find any errors.
Stages in producing an algorithm
• 7 If any errors are found, repeat the process
until you think that your algorithm works
perfectly.
Example – Algorithm to calculate area
of a rectangle
Length  0
Width 0
Area 0
INPUT Length
INPUT Width
Area Length * Width
OUTPUT Area
Tasks

1. Write an Algorithm to calculate the area of a


triangle.
2. Write an Algorithm to calculate the area of a
circle. (remember pie = 22/7 = 3.1429
Programming constructs

There are 3 programming constructs namely:

1. Sequence
2. Selection
3. Iteration
Sequence
1. In sequence a block of statements is
executed in the order they are given and
each statement is executed once.
Structure
Start
<Statement 1>
<Statement 1>
<Statement 1>
End
Sequence
1. Example

Start
Total  0
Number1, Number 2 , Number 3,  0
INPUT Number1
INPUT Number 2
INPUT Number 3
Total  Number1 + Number 2 + Number3
OUTPUT Total
End
Sequence
1. An algorithm to accept 4 numbers and
calculate the total
rithm

Start
algo

Total 0
his
ent t

Number1, Number2 , Number3, Number4  0


lem

INPUT Number1
basi m to imp

INPUT Number 2
INPUT Number 3
in vi a progra
c

Total  Number1 + Number2 + Number3 + Number4


sual

OUTPUT Total
e
Writ

End
Task
1. Write an algorithm to accept 4 numbers and calculate the
average.

2. Write an program to accept 4 numbers and calculate the


average.
Selection
In Selection a statement or block of statements is
executed depending on a condition.
Structure
START
<Statement 1>
IF <Condition> THEN
<Statement 2>
<Statement 3>
ELSE
<Statement 4>
ENDIF
<Statement 5>
END
Selection
In this case Statement1 and Statement5 are
outside the condition so they will be executed
regardless of the condition.

Statement2 and Statement3 will be executed


if the condition is true and Statement 4 Will
only be executed if the condition is false.
Selection
Example
START
Dress up
IF <It is raining> THEN
Carry an umbrella
ELSE
Put on shades
ENDIF
Go to school
END
Selection
Example 2
START
INPUT Number1
INPUT Number2
IF Number1 > Number 2 THEN
OUTPUT Number1 “IS Bigger”
ELSE
OUTPUT Number2 “IS Bigger”
ENDIF
OUTPUT “Thank you”
END
Selection ?

Write a program to input 3 numbers and printout the


smallest number from the 3.

Research on the select case statement.


Num1- 0
Num2-0
Num3-0
Input "enter number1", Num1
Input "enter number2", Num2
Input "enter number3", Num3
IF Num1 < Num2 AND Num1< Num3
THEN OUTPUT "smallest number is", Num1
ElSEIF Num2< Num1 AND Num2< Num3 THEN
OUPUT"smallest number is", Num2
ElSEIF Num3< Num1 AND Num3< Num2 THEN
Variable
When we input data for a process, individual values need to be stored in memory. We need to be able to refer to a specific
memory location so that we can write statements of what to do with the value stored there. We refer to these named
memory locations as variables.

A variable can be defined as an identifier or a named location which stores values which will/can change during the
execution of a program.

There are different variable types


1. Integer  345
2. String  “Harare”
3. CHAR  ‘A’
4. REAL  340.50
5. Boolean  TRUE
Constants and variables
Data are stored either as constants or as variables. Constants (as you’d expect from the name) have values that are fixed
for the duration of a program. For example, if you were writing a program that converted miles into kilometres you could
set the conversion rate as a constant because it will never change. In this case we could call the constant
ConvertMilestoKm and assign it a value of 1.6 as there are approximately 1.6 km to the mile. Then whenever we want to
convert a distance in miles to its metric equivalent we would multiply it by the constant ConvertMilestoKm.

Notice that the name given to the constant is self-explanatory. We could have just called it Constant1. However, by giving it
a meaningful name it makes the code easier to work with as the program gets bigger. It also makes it easier for anyone else
that looks at the code, to work out what the program is doing.

Advantages
• It makes it easier to find and correct errors/bugs in code. This is called debugging.
• There are many occasions where there are several programmers working on the same program at the same time, so
having a sensible naming convention makes it easier for everyone to understand.
• It will be easier to update the code later on when further versions of the program are created.
The value of variables can change as a program is being run. For example, the same conversion program will require the
user to type in the number of miles they want to convert. This number will probably be different each time the user enters
data. Therefore, you need to have a variable that you could call NumberOfMiles.

Variable and constant declaration


Declaring a constant or variable means that when you are writing code you describe (or declare) the variables and constants
that you are going to use before you actually use them in your program. Some programming languages force you to declare
the variables and constants you intend to use in your program before you start writing any code. The benefits of doing this
are that it forces you to plan first and the computer will quickly identify variables it does not recognise. There are two parts
to a declaration. You need to supply a suitable name for the constant/variable and you need to specify the data type that
will be used.
Variable
When we input data for a process, individual values need to be stored in memory. We need to be able to refer to a specific
memory location so that we can write statements of what to do with the value stored there. We refer to these named
memory locations as variables.

A variable can be defined as an identifier or a named location which stores values which will/can change during the
execution of a program.

There are different variable types


1. Integer  345
2. String  “Harare”
3. CHAR  ‘A’
4. REAL  340.50
5. Boolean  TRUE
Selection ?

Write a program to input 3 numbers and printout the


largest number from the 3.

Research on the select case statement.


Solution
DECLARE Number1, Number2, Number3 : INTEGER
INPUT “Enter Number 1”, Number1
INPUT “Enter Number 2”, Number2
INPUT “Enter Number 3”, Number3
IF Number1> Number2 AND Number1 > Number3 THEN
OUTPUT Number1, “Is the largest”
ENDIF
IF Number2> Number1 AND Number2 > Number3 THEN
OUTPUT Number2, “Is the largest”
ENDIF
IF Number3> Number1 AND Number3 > Number2 THEN
OUTPUT Number3, “Is the largest
ENDIF
Alternative Solution

A nested IF is an if within an if, it can be used for


multiple selections in place of using the AND to join
the IFs
Alternative Solution
DECLARE Number1, Number2, Number3 : INTEGER
INPUT “Enter Number 1”, Number1
INPUT “Enter Number 2”, Number2
INPUT “Enter Number 3”, Number3
IF Number1> Number2 THEN
IF Number1 > Number3 THEN
OUTPUT Number1, “Is the largest”
ELSE
OUTPUT Number3, “Is the largest”
ENDIF
ENDIF
IF Number2 > Number1 THEN
IF Number2 > Number3 THEN
OUTPUT Number2, “Is the largest”
ELSE
OUTPUT Number3, “Is the largest”
ENDIF
ENDIF
? Selection
Write an algorithm to input 3 numbers and
output the smallest of the 3 numbers.
? Selection
Given the following grades
80 to 100  Distinction
60 to 79  Credit
50 to 59  Pass
0 to 49  Fail

Write an algorithm to grade students marks


Solution
DELCARE Mark : Integer
DECLARE Grade : STRING
INPUT “Enter mark”, Mark
IF Mark >= 80 THEN
Grade = “Distinction”
ELSEIF Mark >= 60 THEN
Grade = “Credit”
ELSEIF Mark >= 50 THEN
Grade= “Pass”
ELSEIF Mark >= 0 Then
Grade = “Fail
ENDIF
OUTPUT “The grade is”, Grade
Solution
Dry run the algorithm with the following marks

80, 70,12,106,51, 0, -10, 50


? Selection
Given the following grades
80 to 100  A
60 to 79  B
50 to 59  C
40 to 49  D
30 to 39  E
20 to 29  F
0 to 19  U
Write an algorithm to grade students marks
Case
• CASE statements allow one out of several branches of code to be executed, depending on the
value of a variable.
• CASE statements are written as follows:
• CASE OF <identifier>
• <value 1> : <statement1>
• <statement2>
• ...
• <value 2> : <statement1>
• <statement2>
• ...
• ...
• ENDCASE
Case
• An OTHERWISE clause can be the last case:
• CASE OF <identifier>
• <value 1> : <statement1>
• <statement2>
• ...
• <value 2> : <statement1>
• <statement2>
• ...
• OTHERWISE : <statement1>
• <statement2>
• ...
• ENDCASE
Case
Example

INPUT “Enter Grade”, Grade


CASE OF “A” : OUTPUT “Well done”
CASE OF “B” : OUTPUT “Well Tried”
CASE OF “C” : OUTPUT “Fair”
OTHERWISE: OUTPUT “Try again”
ENDCASE
Task
Write an algorithm using CASE to input a mark and grade the mark using the following grades

90 – 100  A*
70 – 89  A
60 – 69  B
50 – 59  C
45 – 49  D
35 – 44  E
0 – 34  U
Iteration - Loop
In iteration a statement or block of statements is
executed for a number of times until a condition
becomes true or false.
Structure
START
<Statement 1>
WHILE <Condition> DO
<Statement 2>
<Statement 3>
ENDWHILE
<Statement 4>
END
Iteration
In this case Statement 1 and Statement 4 are
outside the condition so they will be executed
regardless of the condition.

Statement 2 and Statement 3 will be


executed repeatedly until the condition
becomes false or true.
Iteration
Example
START

Dress up
WHILE <you are hungry> DO
eat some food
drink water
ENDWHILE
Clean up
END
Iteration / loop
There are 3 types of iteration constructs
1. Loop for a specified number of times
2. Test on entry
3. Test on exit

Loop for a specified number of times.


This loop is used when the number of iterations is known before starting the loop, for
example if you are to enter marks for 20 students you know before starting that you
are going to loop 20 times and you use the FOR … NEXT loop
FOR i = 1 to 20
INPUT mark
NEXT i
Write program / algorithm to output numbers from 1 to 10 using
a for loop

Write program / algorithm to output odd numbers from 1 to 19


using a for loop

Write program/algorithm to output numbers 10,9,8,7,…1 using


a for loop
Test on entry
This loop will test a condition before going into the loop. With this loop statements in the loop

can be executed 0 times if the condition is not true at the start of the loop
Example:

START

Dress up
WHILE <you are hungry> DO
eat some food
drink water
ENDWHILE
Clean up
END
In this case if you are not hungry at the start of the loop you will not enter the loop you go to
ENDWHILE.
Write program / algorithm to output numbers from 1 to 10 using
a while (test on entry) loop

Write program / algorithm to output odd numbers from 1 to 19


using a while (test on entry) loop

Write program/algorithm to output numbers 10,9,8,7,…1 using


a while (test on entry) loop
Test on exit
This loop will test a condition after executing the conditions in the loop at least once. With this
loop, statements in the loop will be executed at least once.

Example:
START
START Dress up
DO
Dress up eat some food
REPEAT drink water
eat some food UNTIL <you are satisfied>
drink water Clean up
END
UNTIL <you are satisfied>
Clean up
END
Write program / algorithm to output numbers from 1 to 10 using
a REPEAT UNTIL (test on exit) loop

Write program / algorithm to output odd numbers from 1 to 19


using a REPEAT UNTIL (test on exit) loop

Write program/algorithm to output numbers 10,9,8,7,…1 using


a REPEAT UNTIL (test on exit) loop
Pseudocode to output largest out
of 100 inputs
The program on the previous slide would work when you want to output the largest number from a
limited number of input. Consider the next question;

Write an algorithm in pseudocode to accept


100 numbers and output the largest.
Pseudocode to output largest out
of 100 inputs
Making 100 comparisons will be difficult using the structure of the pseudocode we
have been using. The only way this problem can be solved without running into
logical spaghetti is the use of a loop.

Since the number of numbers to be compared is already known, we will use a FOR
… NEXT loop.
1. Declare variables – in this case 2 variables will be used:
• Number
• Largest

2. Initialise Largest to a very small number e.g. 0 (why ?)


Pseudocode to output largest out
of 100 inputs
The solution
Start Data 56,5,18,70, 30,68
DECLARE Number : INTEGER I Number Largest Output
DECLARE Largest : INTEGER
Largest  0
FOR I  1 to 100
INPUT “ENTER Number” Number
IF Number > Largest THEN
Largest  Number
ENDIF
NEXT I
OUTPUT “The largest number is “ Largest What would have been the output if we had
Stop initialised our variable Largest  90.
Pseudocode to output smallest
out of 10 inputs
Task

Write a algorithm in pseudocode to accept 10


numbers and output the smallest, draw a
trace table and show the result for the
following test data.
Data 91,7,5,9,15,80,60,45,30,71
Rogue data to terminate a loop
The for loop is only applicable in situations where the number input data is known
beforehand. In situations where the number of input data is not known rogue data
can be used to terminate the input. For example a program to accept a set of
numbers and output the largest can be structured as follows using -1 as rogue data.
Start Data 7,67,18,50,30,80,-1,88,90
DECLARE Number, Largest : INTEGER Number Largest Output
Largest 0
INPUT Number
WHILE Number <> -1 DO
IF Number > Largest THEN
Largest  Number
ENDIF
INPUT “Enter number “ Number
ENDWHILE
OUTPUT “The largest number is” Largest
START
Complete the trace table for the input values 4, 3, −1:

INPUT A OUTPUT B A B C OUTPUT

IS Yes B A
A > 0 ? B B + A C C – 1
C A

No
IS
C <= 1 ?
OUTPUT Yes
'Exit'
No

END
(a) Rewrite the following pseudocode algorithm using a
WHILE … DO … ENDWHILE loop.
INPUT Num
FOR Counter ← 1 TO 12
Num ← Num * Counter
A[Counter] ← Num
NEXT

(b) Explain the differences between a WHILE … DO …


ENDWHILE and a REPEAT … UNTIL loop.
Points to consider when writing pseudocode
• Use meaningful identifiers (variable names) – Why?
• Indent your pseudocode accordingly ?
• Leave white spaces
• Use comments
• Capitalisation of Keywords
• Use of (library/built-in) functions
Useful features of IDE which help when coding
• PrettyPrint // Colour coding
Colour coding of command words / key words
• Expand and collapse code blocks
Allows programmer to focus on a section of code // allows quicker navigation of the code
• Auto(matic) indentation
Allows the programmer to clearly see the different code sections / easier to see the code
structure
• Suggestive typing / auto-completion / context sensitive prompts
Gives the programmers ideas on how to complete keywords to minimise errors

• Dynamic syntax checking // Identification of syntax errors

Enables the programmer to identify errors before moving on with the code .
Useful features of IDE which help when coding
Highlighting undeclared variables // incorrect variable usage...
Parameter checking
Type checking
Text editor (for example a function such as copy & paste)
Built-in (library) functions
Identifier table

An identifier table contains a list of variables/ identifiers


used in a program, what they are used for and the data
types
Identifier Description Data Type
StudentName The name of a student STRING
Mark Mark obtained by a student in an INTEGER
exam
Position Student position in the class INTEGER
Decision Decision on pass or fail BOOLEAN
Constants

Why should we use constants where appropriate

The value cannot accidentally get changed and as such will remain the
same throughout the program. When used in different places it will remain
the same minimizing errors.

When there is need for the constant to be changed a change to the value
requires changing in one place only.

You don’t have to repeatedly write out the same value throughout the
program.

For example Pi = 3.14


When things go wrong / survival
Dry run the code
You can use of white box testing (to be discussed in detail later) also use trace tables. You must
trace the contents of variables, trace all possible routes through the program

Breakpoints
Run the code to a set point to find error

Variable watch
Check the contents of variables at specific points in the program

Stepping
Execute the code line by line

Include OUTPUT statements in the code


to display the value of variables as the code was running
Transfer of skill
Transfer of skill

Knowledge / experience of one programming language


which can be applied to an unknown language. Usually
will help recognise control structures, assignment
statements, declaration statement, comments, etc
Introduction to modules
Modules provides a means of decomposing a task into
sub tasks.
A procedure groups together a number of steps and
gives them a name (Identifier) we can therefore use the
identifier when we want to call the sequence of steps

In pseudocode we can say CALL Circle(), CALL


Triangle() to call the procedures Circle and triangle,
however with program code we just write the name of
the procedure in main like Circle()
Introduction to modules
Modules can be customised by a programmer to do a
particular task in a program.

A module can be implemented as a procedure (sub) or a


function. They both can receive parameters but:
• A procedure cannot return a value
• While a function can return a value
Introduction to modules
We are going to create two
procedures and one function.

Procedure – Triangle
Function - Circle
Procedure - Rectangle
Introduction to modules
FUNCTION Circle (ByRef Radius : INTEGER) RETURNS REAL
CONSTANT Pi : REAL  3.14
DECLARE Area : REAL
Area  Pi * Radius ^ 2
RETURN Area
ENDFUNCTION
Homework

Write a module to output the Fibonacci sequence from 0,1,1,2,3… to 55

Write a module to solve the quadratic equation given the values for A,B
an C.
Test your program with x2 – 5x + 6 = 0 ( 3 and 2 )
5x2 + 6x + 1 = 0

• Call your modules from the main program

Those who are done can implement the number guessing game as a
programRWorked example 12.07 page 195 from the textbook-0.2 or -1)
Next up

Flowcharts
Flow chart symbols
Symbol Description Example

Terminator, denotes the start or end of a flowchart


Start
Input / Output used to denote data input or output. Input/ output will
have 1 entry point and 1 exit

Input Num1, Num2

Decision used to represent a decision in an flowchart. It has one input and


two outputs which could True or False / Yes or No
Num1> Num2?

Process used to denote processing which could be making calculations or


assigning a value to a variable.
Num1 = Num1 + 5

Off page connector, used to link part of a flow chart to the other part on
another page, if it fails to fit on one page

Call a function, can be used for input where the function will pass value or
reference to the calling program
Mark  GetMark(StMark)
Tasks

Draw a flow chart to


1. Calculate the area of a triangle
2. Calculate the area of a circle
3. Input 10 Numbers and output the Largest, Smallest, Average
( -0.2 or -1)
Tasks
Tasks

Draw a flow chart to represent the following pseudocode

FOR Index 1 TO 26
CharCount[Index]  0

ENDFOR ( -0.2 or -1)


Tasks

Draw a flow chart to represent the following pseudocode

FOR Index 1 TO 26
CharCount[Index]  0

ENDFOR ( -0.2 or -1)


Tasks
Tasks
Tasks

(b) Draw a program flowchart to represent the pseudocode algorithm.


Variable declarations are not required in program flowcharts. ( -0.2 or -1)
Tasks

Write pseudocode to implement


the algorithm represented by the
flowchart. ( -0.2 or -
1)
Tasks

A program will:
• input 50 unique integer values
• output the largest value
• output the average of the values excluding the largest value.
Draw a program flowchart to represent the algorithm.
Variable declarations are not required.
It is not necessary to check that each input value is unique. ( -0.2 or -1)

You might also like