Form Three Notes
Form Three Notes
Introduction:
- In digital computers the user input is converted and
transmitted as electrical pulses represented in two
states: “1” and “0” before processing.
- Data stored in a computer is usually in forms of bits/
binary digits. It is only in this form of representation
and the computer micro- processor can retrieve stored
information and manipulate it.
- The computer system is made up of logic that works
only with states “ON” and “OFF’ represented by the
two distinct digits “0” and “1” respectively.
KCSE 2006
1. What is meant by?
- Analog data: they are quantities that are continuous
and infinite variety of values e.g. temperature,
pressure, flow rate, current, voltage.
- Digital data: they are input data, which uses two
discrete states e.g. ON/OFF, YES/NO, HIGH/LOW,
RIGHT/WRONG.
Kcse 2005
Arrange the following data units in ascending order of size
BYTE, FILE, BIT, NIBBLE (2 marks)
Answer: BIT<NIBBLE<BYTE<FILE {marked as a
whole}
Kcse 2007
5
= 6 6 x 100
= 40 4 x 101
= 900 9 x 102
= 3000 3 x 103
3946
The base value (radical base) depends on the type of
number system that is being used, for decimal system is 10.
The weight of each position is multiplied by the
corresponding digit to obtain the value of that positional.
The values of each position are then added to obtain the
number.
In any number, the right most digit has the most value and
is called the most significant digit (MSD)
2
1x = 1
1
Total 11
72458 7 x = 7 x = 3584
83 512
2 x = 2 x = 128
82 64
4 x = 4 x 8 = 32
81
5x = 5x1 = 5
80
The decimal equivalent is : N10 = 3749
Note:
The main advantage that the octal and hexadecimal
numbers have over decimal numbers is that they can easily
be converted to and from binary numbers.
digit
Note:
Remember always to indicate the base subscript since it’s
the value that distinguishes the different number systems.
Multiply each digit by its place value
12
There are two possible methods the long division and the
place value method.
In the long division method, divide the decimal number
repeatedly by 2 until the quotient is 0. Then write the
remainder which is either 1 or 0 to the right of quotient, and
read it in reverse order i.e. from the bottom upwards. The
series of 1’s and 0’s obtained represent the binary
equivalent of the number.
Example\convert 157 to binary.
2 157 Rem
2 78 1
2 39 0
2 19 1
2 9 1
2 4 1
2 2 0
2 1 0
2 0 1
13
Note
Whatever is on the left of the period is equated to zero
when multiplied or you simply have it as a zero. The
equivalent of the fractional part is extracted from the
products by reading the respective integral digits from top
to down.
Example
Convert 76.2510 to binary
2 76 Rem
2 38 0
2 19 0
2 9 1
2 4 1
2 2 0
2 1 0
2 0 1
7610 = 10011002
For a binary is the same approach only that the weights are
based on factors of 2 e.g 110110112
Place 21 20 . 2-1 2-2 2-3 2-4 2-5
value
Binary 1 1 . 1 1 0 1 1
digit
Value in 2 1 . 0.5 0.25 0 0.062 0.0312
base ten 5 5
Example:
Convert 11.0112 to a decimal number
Place value 21 20 . 2-1 2-2 2-3
Binary digit 1 1 . 0 1 1
Value in 2 1 . 0 0.25 0.12
base ten 5
2 1 . 0 0.25 0.12
5
0.5 x 0 = 0.000
0.25 x = 0.250
1
0.125 = 0.125
x1
0.37510
Example 2
Convert the octal number 11118 to its base 10
equivalent.
Soln.
Place value 83 82 81 80
Octal digit 1 1 1 1
Work out
512 x 1 = 51
2
64 x 1 = 64
8x1 = 8
1x1 = 1
585
Therefore 11118 => 58510.
18
20
Example:
Convert 0111011.0102 to octal.
First group into three bits from right to left in the integral
part, then from Left to Right in the fractional part.
222210 222210 222210 2-12-
2 -3
2
000 111 011 . 010
0 7 3 . 2
NB:
If a digit is a letter e.g. ‘A’ write its decimal
equivalent.
Example:
Convert 7AE16 to decimal
Soln.
7 A E
2 1
16 16 160
(7 x 162) (10 x 161) (14 x 160)
1792 160 14
1966
Therefore 7AE16 196610
A C 2 7
22
Hexadecimal Binary
equivalent
0 0000
1 0001
2 0010
3 0011
4 0100
5 0110
6 0111
7 1000
8 1001
9 1010
A (10) 1011
B (11) 1100
C(12) 1101
D (13) 1101
E (14) 1110
E (15) 1111
23
Example:
Convert 91B16 into Octal.
Soln.
9 - 10012
1 - 00012
B(11) - 10112
100100011011
Group into 3 bits
24
Therefore =
21116
Conversation from decimal to Octal
Divide repeatedly by 8 until the last result of the division is
0. Then write the remainder of the numbers going upwards.
Example
25
8 123 R
8 15 3
8 1 7
0 1
For the fractional part, multiply this part by 8, that is you
can only
0.50 x 8 = 4.00
For the fractional part, multiply this part by 8, that is 0.5 x
8 = 4.00.
You only use complete units and you read downwards,
123.510 173.48
6 = 1102
Group into 4 bits 0 ,1111, 1110 then convert into
hexadecimal as follows:
i). ( 23 x 1 + 22 x 1+ 21 x 1 + 20 + 1) = 15 (F)
ii). (23 x 1 + 22 x 1 + 21 x 1+ 0 x 20) = 14 (E)
Therefore 3768 FE16
Or
Change octal to decimal first then from decimal to hex as
follows;
3768 3 x 82 + 7 x 81 + 6 x 80 = 25410
Divide the decimal repeatedly by 16 to change to
hexadecimal.
1 254
6
1 15 R 14(E)
6
0 R 15 (F)
= FE16
27
Question:
Write the number 45110 in BCD notation.
Soln.
Workout each digit binary equivalent independently, where
he digits are less than 4 add 0s on the left to make 4 bits
4 = 0100
5 = 0101
28
1 = 0001
45110 = 010001010001BCD
29
Ones complement
The 1’s complement of a binary number is found by simply
changing all 1’s to 0’s and all 0’s to 1’s e.g. -2110 can be
represented in binary as a negative value as follows.
2110= 101012
Therefore -2110 010102 (by complementing each
binary digit / bit).
Therefore -2110 = 010102 (1’s complement method.)
Two’s complement
30
Signed magnitude
In decimal numbers, signed numbers has a prefix “+” for a
positive number e.g +3210 and “-“ for a negative number
e.g. -3210. in binary a negative number may be represented
by prefixing a digit 1 to the number while a positive
number may be represented by prefixing a digit number 0.
i.e. 1710 => 100012 (unsigned)
-1710 => to indicate it’s a negative number we add an extra
bit (1)100012
31
Binary addition
The binary addition is same as for decimal numbers only
that any complete unit of two’s is carried to be added to the
next significant digit. The five possible additions are
A B Sum carry
1. 0 + 0 = 0 0
2. 0 + 1 = 1 0
3. 1 + 0 = 1 0
4. 1 + 1 = 10 1{read as 0,
carry 1}
5. 1 + 1+1 = 11 1{read as 1,
carry 1}
Examples:
i). Find sum of 1112 + 0112
Soln.
1 1 1
+ 0 1 1
10 1 02
Add the two first numbers and then add the sum to the 3rd
number as follows
Step 1
101110
+ 1011
100001
Step 2
1000012
1112
1010002
Binary subtraction
33
Step 1-0 = 1
1
Step 10 – 1 = 1 {borrow 1 to make the
2 current value 102 (22)
from the next significant
digit)
Step 0 – 0 = 0
3
Step 1 – 1 = 0
4
34
5. 1110112 6. 1000102
- 1102 - 112
6. 1000102 – 112 7. 011012 – 10112 8. 1111112 –
101011012
9. 111011012 – 1001112 10. 1000002 - 11112
Example
Subtract 100112 from 110012 using 1’s complement.
Step 1
Minuend => 1’s complement of 100112 = 011002
Step 2
35
Final
result =
001102.
Example:
Subtract 3 from 5 in 8-bits 2’s complement.
+5 Subtrahend 00000101
+(- Minuend 00000011
3)
00000011 which is
Step 2 Add 1 to 1’s complement which 11111100
becomes +1
11111101
-5 1011
-6 1010
-7 1001
-8 1000
Revision questions
1). Explain the two types of data signals.
2). Differentiate between
a). Octal and decimal number systems
b). Binary and hexadecimal number systems
3). Convert the following binary numbers to their decimal
equivalents
a). 1011102 b). 57010 c). 4210 d). 3010
4). Convert the following decimal numbers to their
decimal equivalents.
a). 78910 b). 57010 c). 4210 d).
3010
5). Find the sum of the following binary numbers
a). 11102 + 11112 = b). 0012 + 1002 =
38
40
Kcse 2007
1.Using six bits, find the two’s complement
of -2310. (4 marks)
Kcse 2005
17. (a) Subtract 01112 from 10012
(1 mark)
(b) Using two’s complement, subtract 7
from 4 and give the answer in decimal
notation. (4
marks)
(c) Convert:
(i) 91B16 to Octal
(3 marks)
(ii) 3768 to hexadecimal
(3 marks)
(iii)
41
Data processing
Refers to;
1) Transformation of raw data into meaningful output
(information)
2) The preparation, storage or manipulation of data /
information.
3) The collection, manipulation and distribution of data to
achieve a certain objectives.
Data processing can be done manually, mechanically or
electrically.
Refers to;
1) Input – process – output stage that data goes through to
be transformed into information.
2) Is when data is collected, input, processed and output
manually or by means of a computer.
Processing
c). Processing
Transformation of input data by the cpu to a more
meaningful output.
d). Output
Is the final activity of data processing cycle which produces
the desired output (information). The information is then
distributed to the target groups or stored for future use.
Distribution (dissemination)
Is the making information available to those who need it.
45
a) Misreading errors.
They are brought about by incorrect reading of source
document by the usre and hence entering wrong values.
Example typing 2754 instead of 2154; typing wrong
characters e.g. datat instead of data. There are also
omission errors where a character has been missed onto.
These errors may be caused by bad handwriting or
confusion on the source document. Example 0 instead of
letter o.
b) Transposition errors
Are errors which occur due to a mistake made by
interchanging (incorrect arrangement) of two correct
characters or numbers during typing e.g. typing 7754
instead of 7745. Transcription errors can be eliminated
by use of data capture devices..
46
47
48
ELEMENTARY PROGRAMMING
PRINCIPLES
CONTENT
1. Definition of programming
2. Levels of programming languages
3. Advantages and disadvantages of
low and high level programming
languages
4. Description:
(i) assembler
51
(ii) compiler
(iii) interpreter
(iv) source program
(v) object program
5. Program development (stages)
6. Program control structures
7. Definition and development and
development of algorithms, pseudocodes
and flowcharts
SPECIFIC OBJECTIVES
By the end of the topic, the learner should
be to:
(a) Define programming
(b) Describe various levels of
programming languages
(c) State the advantages and
disadvantages each level of
programming languages
(d) Define the terms: assembler,
compiler, interpreter, source program
and object program
52
INTRODUCTION
A computer works by executing set of
instructions called programs. A program is a
set of instruction given to the computer to
perform various operations on the data
supplied to it; and has to be planned in an
orderly fashion.
The instructions as well as the data are
placed simultaneously in computer memory
in the form of bits (binary digits)
The function of a program is to enable the
computer to perform a specified activity.
E.g. producing payroll, updating sales ledger
balance, performing calculations etc
53
Programming
Language, in computer science, artificial
language used to write a sequence of
instructions (a computer program) that can
be run by a computer. Similar to natural
languages, such as English, programming
languages have a vocabulary, grammar, and
syntax. However, natural languages are not
suited for programming computers because
they are ambiguous, meaning that their
vocabulary and grammatical structure may
be interpreted in multiple ways. The
languages used to program computers must
have simple logical structures, and the rules
for their grammar, spelling, and punctuation
must be precise.
55
LEVELS OF PROGRAMMING
LANGUAGES
Classified into two major classes:
1. Low-level programming languages
2. High-level programming languages
LOW-LEVEL LANGUAGES
Low-Level Language, in computer science,
a computer programming language that is
machine-dependent and/or that offers few
control instructions and data types. Each
statement in a program written in a low-
level language usually corresponds to one
machine instruction.
They are classified as low because they can
be easily understood by the computer
directly. They require no translation since
they are in computer understandable form or
hardware oriented. There they are not
portable i.e. a program written for one
computer cannot be installed and used in
another.
Types of low level languages
58
60
62
63
64
67
68
Text box
Text box
72
Definition of terms
73
Interpreters Compilers
1. Translates the - Translates the entire
74
this.
A list-oriented programming
language, mainly used to
manipulate lists of data.
Interpreted language, often
LISP LISt Processing 1960
used in research, generally
considered the 'standard'
language for Artificial
Intelligence (AI) projects.
Programming language often
used with children. Features a
Derived from
simple drawing environment
LOGO Greek logos, 1968
and several higher-level
meaning word
features from LISP. Primarily
educational.
MODULAr
Language that emphasizes
Language,
modular programming. High-
designed as
Modula- level language based on
secondary phase 1980
2 Pascal, characterized by lack
of Pascal (Niklaus
of standard functions and
Wirth devised
procedures.
both)
Compiled, structured
Blaise PASCAL, language, based on ALGOL.
mathematician Adds data types and
Pascal and inventor of 1971 structures while simplifying
first computing syntax. Like C language, it is
device a standard development
language for microcomputers.
PERL Practical 1988 It is a text-processing
78
79
PROGRAM DEVELOPMENT
Software designers create new programs by using special
applications programs, often called utility programs or
development programs. A programmer uses another type of
program called a text editor to write the new program in a
special notation called a programming language. With the
text editor, the programmer creates a text file, which is an
80
81
important so that the facts are recorded when they are still
fresh and in the required detail by the programmer.
The completion of each stage leads to the beginning of the
next. Some stages have to be continuously reviewed to
make sure that they meet the requirements. E.g. after
coding the code has to compared with design to see
whether it meets design specifications.
1. Problem recognition
This is also called problem realization or problem
identification. It is basically a problem solving exercise.
The programmer identifies problems in the environment
and seeks to solve them by writing a computer program that
would provide a solution. Problem recognition refers to the
understanding and interpretation of a particular problem. To
understand a problem you need to look at key words such
as compute, evaluate, compare etc.
The following situations can cause a programmer to
identify a problem that is worth solving:
(a)Problems or undesirable situations that prevent an
individual or organization from achieving their
purpose
(b)Opportunity to improve the current program. It can
be argued that any unexploited opportunity is a
problem.
82
2. Problem definition
Involves explaining how the program will solve the current
existing problem. It is also referred to as problem analysis.
It also involves explaining the kind of input to be expected,
processing activities and expected output.
Example: In a problem of calculating the area of a circle, an
investigation reveals that the parameters needed to
determine the area are:
Input: - Pie () which is constant
- The radius of the circle
Process: The formula of calculating area of a circle which
is- *r*r
Output: The area of the circle (A)
83
3. Program design
This is the actual development of program’s processing or
problem solving logic called algorithm. Algorithm refers
to a definite number of steps that a program follows in
order to solve a problem. It’s the programmer who usually
comes up with algorithm after carefully analyzing the
requirements specifications. Pseudocodes and flow charts
can also be used.
It involves the identifying of the processing tasks required
to carry out the problem solution. the task must be in order
and systematic.
Many programs are not usually made up of one large block
of code i.e. they are not monolithic. Instead several units
called modules work together to form a whole. In modular
programming each module performs a specific task. This
approach makes program flexible, easier to read and correct
errors. In this stage the programmer come up with models
of the expected program.
4. Program coding
This is a process of converting the design
specification/model into actual computer instructions
(program). It involves typing the program using a particular
programming language application software e.g. Pascal,
84
85
Logical errors
These are errors in the program logic. The program runs
but gives wrong output (results) or halts during
execution. i.e. makes program produce wrong results or
run-time error (premature end).
NB: Logical errors are not detected by translators.
Solution to logical errors is to check on the code to
rectify the logic.
4. Diagnostic procedure
If the program is made up procedures or sub-divisions,
test each procedure independently.
Other errors: run-time errors, execution errors
6. Implementation and maintenance
Implementation refers to actual delivery and
installation of the new program ready for use. New
programs will change the way things are done hence
need for review and maintenance.
Review and maintenance
This is important because of the errors that may be
encountered after implementation and exposing the
89
This chapter is meant to equip you with the main skills for
writing a comprehensive computer studies project.
System classification
i). Deterministic system
Are systems whose outputs are known precisely by
their inputs e.g. a computer system.
ii). Probabilistic system
Are systems whose output can only be predicted but
not known precisely e.g. business and economic
system organizations.
93
Characteristics of systems
i). Holistic thinking
A system is considered as a whole. A Greek
philosopher called Aristotle said that the whole is
more than the sum of the parts. A combination of the
various components that make up a system may be
simple in nature and process but their combination
creates a complex whole; whose overall goals are
more sophisticated than those of individual
components. Therefore a system should be considered
as a whole unit, rather than considering its parts
individually.
iii). Processor
94
v). Purpose
Each system is established to perform a particular task
or achieve a goal. The objectives that a system is
supposed to achieve enable system developers to
measure the performance of a system during its
operation.
95
ix). Control
Is the process by which the system adapts to changes
in the environment in order to give the expected
output or to perform to the expected level. Control is
achieved through feedback. Feedback involves having
output from the process of the system being fed back
to the control mechanism, which in turn makes sure
that the output meets the set expectations.
Input System process
Control
signal Feedback
96
Control
x) Interdependence
For a system to be effective and efficient, its components
or subsystems must be coordinated and linked together.
98
Traditional approach
Rapid application development
(RAD)
The structured approach
102
Disadvantages of RAD
The working system may have over sights and weaknesses
due to the quick development.
Technical feasibility
106
Economic feasibility
It establishes whether the projected benefits of
the proposed system outweigh the estimated
costs involved in developing or purchasing,
installing and operating it. I.e. it involves
benefits and costs.
Schedule feasibility
It is concerned with whether the system can be put into use
within the stipulated time.
Legal feasibility e.g. government policies, laws etc
Social feasibility – acceptability of the system by the users
or organization.Add on: What are the Types of
Feasibility Studies?
107
109
b). Interview
110
Advantages of interview
- The analyst gets first hand information
111
Disadvantages of interviews
- Some interviewees give answers which are
not actually proven facts but opinions.
- The interviewee may not fully open on some
issues that may be personal / sensitive.
- Interviewee may be suspicious of the
intentions of the proposed system for fear of
being displaced by new system.
Questionnaires
A questionnaire is a document containing a
number of standard questions set to collect
information and opinions from the people who
receive and respond to it.
Advantages of questionnaires
- answers are filled in less tense environment
113
Disadvantages
- it’s slow
- designing questionnaires requires expertise
- if a questionnaire is misunderstood, ambiguous
replies are received
- it requires a lot of time to analyse the
questionnaires
d). Observation
it involves watching an operation closely and
participating for a period of time to see for oneself
what exactly happens about the system.
Advantages
- the analyst gets the first hand information about
the problems and exposes him/her to the system
requirements.
- Concepts that are too difficult for non-technical
staff to explain can be observed
114
Disadvantages
- costly and time consuming
- person being observed might alter behaviour
leading to wrong requirements being observed
- staff members are not comfortable when they are
being watched
115
Output specifications
The main interest from a system is information
(output) which is given the first consideration. You
116
Input specification
The inputs are required to produce the output. The
contents of the input are used to maintain the
master files.
119
System changeover
The process of putting the new information
system online and retiring the old system
(move from the old system and start using
the new).
There are four changeover methods which
are:
Advantages
- If there are any errors in the new system,
you can make changes as you use the old
system
- Personnel become familiar with the new
system prior to actual changeover
- Has lower risks to business operation
- There is thorough testing of the new
system
Disadvantages
128
Advantages
- Allow the system to be implemented
quickly
129
- Less costly
- Failures of the system are limited
- Causes minimal disruption
- Avoids traumatic effect of trying to
implement all the components at once.
Disadvantages
Problems on ensuring that the first phase is
implemented and converted.
Types of maintenance
Some of the main types of System
Maintenance are:
user requirements.
System documentation
System documentation is a written graphical
record of the steps taken during the system
development lifecycle. Any maintenance
work must be documented in order to update
the existing documentation.
138
User Manuals
These are the easiest to read and use,
and are designed for the non-technical
reader who wants to start with "how to
switch it on" and use it. It may even
show where the “On” switch is. (Don’t
laugh – people ask!)
When designed for software packages,
these guides are designed to provide
the user all the information they need to
use the software to perform a range of
tasks. A well designed user guide can:
reduce support calls
help new staff perform daily tasks
help experienced staff perform
infrequent tasks
standardise work practises.
139
141