1chp8 Programming
1chp8 Programming
Basic concepts
When writing the steps required to solve a problem,
the following concepts need to be used and
understood:
» sequence
» selection
» iteration
» counting and totalling
» string handling
» use of operators.
Sequence
The ordering of the steps in an algorithm is very
important. An incorrect order can lead to incorrect
results and/or extra steps that are not required by
the task.
Example:
BEGIN
DECLARE num, result : INTEGER
OUTPUT "Enter a number for calculate the power of the number"
INPUT num
result num*num
OUTPUT "Power of the Number:" + result
END
Selection
Selection is a very useful technique, allowing
different routes through the steps of a program.
These are:
» Count-controlled loops(for a set number of
iterations)