Programming Theory
Programming Theory
Theoretical
Structure
diagrams
Program Algorithms:
It sets out the steps on a piece of paper to complete a given task in order to solve a problem. This
Algorithms
can be done either by flowchart or pseudo code.
Flowchart It is a graphical representation of the steps required for a task using standard shapes.
Pseudo It is a simple method of showing an algorithm, using English like words and mathematical operators
code that are set out to look like a high-level program notation.
Data Testing:
Data Verification:
To minimise errors occurred while transferring data or transcripting data from one source to another.
This is usually carried out by the user/operators by one of the following methods:
1 Sight check (visual check/screen check):
It is a manual check completed by the user who is entering the data. When the data entry is
complete the data is displayed on the screen and the user is asked to confirm that it is correct
before continuing. The user either checks the data on the screen against a paper document
that is being used as an input form or confirms from their own knowledge if the data is about
them.
2 Double data entry check:
the same user (or 2 different users) enter the data twice to the computer. Both entries are
compared by the computer, if they are equal, so assumed to be entered correctly
3 Parity check
A parity bit is added to the bits/byte needed to be transmitted, to adjust the number of 1s on
the bytes, as before data is transferred, an agreement is made between sender and receiver
regarding which of the two types of parity are used, EVEN PARITY: have an even number of 1-
bits; ODD PARITY have an odd number of 1-bits.
4 Check sum
When a block of data is about to be transmitted, the checksum for the bytes is first of all
calculated. This value is then transmitted with the block of data. At the receiving end, the
checksum is recalculated from the block of data received. This calculated value is then
compared to the checksum transmitted. If they are the same value, then the data was
transmitted without any errors; if the values are different, then a request is sent for the data
to be retransmitted.
Check digits are used for barcodes, product codes, International Standard
Book Numbers (ISBN) and Vehicle Identification Numbers (VIN).
Uniqueness Checks that the data entered doesn't have any duplicates (for example:
9
check email address, account number, card number…etc)
Note:
In order to validate the data, we have to have clear set of rules that can be used (for example, fixed
length, fixed values..etc)
Reason of using: Used in calculations, also it’s defined only once, and referenced many times in
a program, thus, if you want to change the value of this constant it will be changed ONCE only
Array/list It is a container which can hold a fix number of items and these items should be of the same
type. Each array use the following terms:
• Element: Each item stored in an array is called an element.
• Index: Each location of an element in an array has a numerical index, which is used to
identify the element.
In order to repeat the same task many times for all the items in a list, each item needs to be
referred to in the same way using the index number for each element of the one -dimensional
array (for example: for i = 1 to 50, input name[i], next i)
Note: A statement should not refer to a group of array elements individually. For example, the
following construction should not be used.
StudentNames [1 TO 30] ß ""
Instead, an appropriate loop structure is used to assign the elements individually. For example:
FOR Index ß 1 TO 30
StudentNames[Index] ß""
NEXT Index
Storing data with correct data type is very important, in order to have an effective manipulation (for
example: numbers in calculations, characters in concatenation), also in some case when choosing the
correct type is like automatic validation (char one digit, Boolean two values only..etc)
Operators:
Note:
Care should be taken with the division operation: the resulting value should be of data type REAL, even if the
operands are integers.
The integer division operators MOD and DIV can be used. However, their use should be explained explicitly and
not assumed.
X
ç
0
Y ç 100 Processing
(Calculations or initializing/assigning)
Z ç 100 X
ç
X
+
1
Read/Write
Input
X
Output
Y
(Input from a keyboard or
output on the screen)
Decision/if