Form 3 Computer NOTES
Form 3 Computer NOTES
studies
Form three
work
1
Table of contents
Data representation in a computer
Data processing
System development
Chapter
Data representation
1 in a
computer
3
Introduction
In digital computers,
the user inputs is
converted and
transmitted as
electrical pulses that
can be represented by
two digits ‘1’ and ‘0’
before processing.
These two digits are
referred to as Binary
digits.
Sending data via a telephone line
When a digital signal is to be
sent over analog telephone
lines e.g. e-mail, it has to be
converted to analog signal. This
is done by connecting a device
called a modem to the digital
computer. This process of
converting a digital signal to an
analog signal is known as
modulation. On the receiving
end, the incoming analog signal
is converted back to digital
form in a process known as
demodulation.
Concepts of data representation in digital computers
Electronic components
such as microprocessor
are made up of millions
of electronic circuits.
Availability of a high
voltage (ON) in these
circuits is interpreted
as ‘1’ while a low
voltage (OFF) is
interpreted as ‘0’.
Data representation on magnetic media
The presence of a
magnetic field in one
direction on magnetic
media is interpreted as
‘1’ while the absence
of magnetic field is
interpreted as ‘0’.
Data representation on optical media
In optical devices, the presence of light is interpreted as ‘1’
while its absence is interpreted as ‘0’.
BITS – this is a binary digit, which can either be 0 or
1.it’s the basic unit of data or information in digital
computers.
BYTE – a group of 8 bits. It is the basic unit of
measuring memory size in computers.
NIBBLE – it is a half a byte or a group of 4 bits.
WORD – its consists of one or more bytes and is the
largest amount of memory that the computer can handle.
WORD LENGTH – is the number of bits in each
word of computer.
Reading data on a CD-ROM
Types of data representation
Number System
Base conversion
Negative Numbers
Binary Addition
Types of number systems
Decimal Number System
Octal Notion
For fractional
hexadecimal values. The
division is by 16 and the
procedure is the same as
the binary fraction to
decimal.
Hexadecimal to Binary
Examples of hexadecimal to binary
Negative numbers
Both positive and negative numbers can be
represented in the computer memory
during processing. various methods are
used to represent negative numbers in the
computer. These methods are:
i. One’s compliment
ii. Two’s compliment
The negative numbers are used to carry out
subtraction in the computer arithmetic
operations.
One’s complement (1c method)
In this method the binary bits representing the
negative number are negated that is the 1’s in the
number are changed to 0’s and 0’s to 1’s.
Two’s complement (2c method)
In this method, the negative number is represented
into binary, then complimented as in 1c method
but a ‘1’ is added to the least significant digit of
the complement value.
Signed magnitude
In decimal numbers, signed number 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 0.
i.e. 1710 ⇒ 100012 (unsigned)
-1710 ⇒ To indicate it’s a negative number we add
an extra bit (1) 100012
+1710 ⇒ To indicate it’s positive we add an extra bit
(0) 100012
Advantages of two’s compliment
There are no two ways of representing a
zero as in one’s compliment and signed
magnitude.
Binary subtraction
Binary multiplication
Binary addition
Binary addition rules
b. 1510 e. 8910
c. 139010 f. 45510
Review questions 3
Using the place value and log division
methods convert each of the following
base 10 numbers to their binary
equivalents.
a. 1010
b. 4310
c. 36510
d. 51210
e. 143
f. 95410
Answer of review questions 3
a. 10102 d. 10000000002
b. 1010112 e. 100011112
c. 1011011012 f. 11101110102
Review questions 4
1. Convert the 2. Convert the
following binary following decimal
numbers to their numbers into their
decimal equivalents. binary equivalents.
a. 0.100112 a. 0.63510
b. 0.00102 b. 0.45010
c. 0.101012 c. 2.50010
d. 11.01102 d. 5.162510
e. 101.111102 e. 7.187510
f. 100.1102 f. 0.35010
Answer of review questions 4
1. Convert the binary 2. Convert the decimal
numbers to their numbers into their
decimal equivalents. binary equivalents.
a. 0.5937510 a. 0.1012
b. 0.12510 b. 0.011102
c. 0.6562510 c. 10.10002
d. 3.37510 d. 101.001010011
e. 5.937510 e. 111.00112
f. 4.7510 f. 110101.01011102
Review questions 5
Convert the following octal numbers to decimal
numbers.
a. 778
b. 648
c. 1028
d. 12008
e. 10008
f. 1738
g. 1238
h. 7778
i. 3458
j.
k.
1668
3458
Answer of review questions 5
a. 6310 f. 12310
b. 5210 g. 8310
c. 6610 h. 51110
d. 64010 i. 22910
e. 51210 j. 11810
Review questions 6
Convert the following octal numbers to their
binary equivalents.
a. 2448
b. 2478
c. 1628
d. 5658
e. 2228
f. 33708
g. 14138
h. 13318
i. 63478
j. 466538
Answer of review questions 6
a. 101001002 f. 110111110002
b. 101001112 g. 110000110112
c. 11100102 h. 10110110012
d. 1011101012 i. 1100111001112
e. 100100102 j. 1001101101010112
Review questions 7
Convert the following hexadecimal numbers
into decimal numbers.
a. 3216
b. CCD16
c. EFE16
d. 11916
e. 32816
f. ABD16
g. 10AFFD16
h. DDFF3416
i. 11ABDF16
j. CDFF3116
Answer of review questions 7
a. 5010 f. 95410
b. 327710 g. 109362910
c. 383810 h. 1454878810
d. 28110 i. 115811110
e. 80810 j. 1350020910
Review questions 8
Convert the following hexadecimal numbers into binary
form
a. 29416
b. 24716
c. EFD16
d. 90716
e. BAD16
f. CBDF16
g. 585C16
h. ABCD16
i. 55C3A16
j. 33111CF16
k. Convert 1111000110111 to its hexadecimal equivalent.
Answer of review questions 8
a. 10100101002 g. 1011000010111002
b. 10010001112 h. 10101011110011012
c. 11101111111012 i. 1010101110000111
d. 1001000001112 0102
e. 1011101011012 j. 1100110001000100
01110011112
f. 11001011110111112
k. IE3716
Review questions 9
Answer of review questions 9
1. 100012 7.
10001112
2. 101102 8.
1111112
3. 110012 9.
10000002
4. 1100112 10.
110010112
5. 10110012 11.
10010112
6. 101012 12.
Review questions 10
Answer of review questions 10
1. 11112 1.
111112
2. 0012 2. 102
3. 101002 3.
10100102
4. 10012 4.
110001102
5. 1101012 5.
100012
Review questions 11
1. Convert the decimal number -7 to 8-bit binary using
ones and twos complement.
2. Using 8-bits length, find the twos complement of the
following decimal numbers.
A) -3110
B) -2810
C) -510
3. Using ones and twos complement perform the following
arithmetic operations.
A) 1410 – 710
B) 2810 – 1210
C) 3410 – 3310
D) 10010 – 5010
E) 10210 – 6410
Answer the review questions 11
1. 111110012 3. A). 1112
E). 01001122
Revision questions 1
1. Explain the two types of 4. Convert the following
data signals. decimal numbers to their
2. Differentiate between decimal binary
A) Octal and decimal
equivalents.
number systems. A) 78910
B) 57010
B) Binary and hexadecimal
number systems. C) 4210
D) 3010
3. Convert the following binary
numbers to their decimal 5. Find the sum of the
equivalents. following binary numbers.
A) 1110 2 + 1111 2 =
1. 101110
2 B) 0012 + 1002 =
2. 1010112 C) 11012 + 10112 + 1002 =
3. 01102 D) 10102 + 1012 =
4. 101012 E) 1112 + 112 =
Answer of revision questions 1
1. Analog and digital
2. A). Octal number system is a base 8 system while the
decimal number system is a base 10 system.
B). Binary number system is a base 2 system while
hexadecimal number system is a base 16 system.
3. A).
4610
B). 4310
C). 610
D). 2210
4. A).
11000101012
B). 10001110102
Revision questions 2
1. Work out the following binary 3. Determine the value of X in the
subtraction using direct, ones equations:
and twos complement methods. A) 1001102 – X2 = 0010102
A) 11001 – 1101 B) X2 + 11012 = 7010
B) 1000 – 101 4. Work out the decimal equivalents
C) 100011 – 111 of the following binary numbers.
D) 10101110 – 1000110 A) 0.100102
E) 10001000110 – 101 B) 101.112
2. Find the ones and twos C) 11.1012
complement of the following
decimal number in binary form. D) 0.0012
A) -7510 5. Work out the decimal equivalents
B) -8010 of the following binary numbers.
C) -10010 A) 0.3510
B) 2.5010
C) 0.2010
Answer of revision questions 2
1. A). 101012 1. A). 0.562510
B). 1012 B). 5.7510
C). 111002 C). 3.62510
D). 11112 D). 0.12510
E). 10102 2. A). 0.0101102
B). 10.12
2. A). 11002
C). 0.00112
B). 0112
D). 111.0012
C). 111002
D). 11010002
E). 100010000012
3. A). 111002
Revision questions 3
1. Write down the character represented by the following
codes:
A) ASCII
i. 0110000
ii. 0110111
iii. 1000011
iv. 1011001
B) EBCDIC
1. 11110000
2. 11110111
3. 11000001
4. 01011101
Answer of revision questions 3
ASCII Char EBCDIC Char
acter
Num 1’s 2s
acter
ber complement complement
77
Definition of Terms
Data – this is a collection of raw facts (figures, letters,
characters etc) that convey little meaning by themselves.
Information – this refers to data that has undergone
processing and is meaningful to the user when he/she need
it, in the form he needs and at the time he/she need it.
Data processing – refers to the process of
transforming raw facts into meaningful output
(information)
Data processing cycle – refers to input process output
stages that data goes through to be transformed into
information.
Data processing cycle
Data collection
Processing
Stages of data processing cycle
1. Data collection – this involves looking for or getting
the data from its point of origin for processing purpose.
2. Data input – this is the process where the collected data
is converted from human readable form to machine –
readable form.
3. Processing – this is transformation of input data by the
central processing unit to a more meaningful output.
4. Output – this is the final activity of data processing
cycle which produces the desired output (information).
The information is then distributed to the target
groups.
Methods of data collection
Interview
Questionnaire
Observation
Record inspection
Stages of data collection
Depending on the method of data collection
used, the process of data collection may
involve the following stages.
Data creation
Data transmission
Data preparation
Media conversion
Input validation
Sorting
Data creation
This is the process of putting together facts
in an organised format. This may be in form
of manually prepared documents or captured
from the source using data capture devices.
E.g. scanners, digital camera etc.
Data transmission
This refers to the transfer of data from the
point of collection (source) of the point where
processing is to be done. Transmission can be
electronically through computer – to –
computer, physically by the post office etc.
Data preparation
This refers to conversion of data from
source document to machine – readable
form. Data collected using devices that
capture data in digital form do not require
transcription conversion.
Media conversion
Data may need to be converted from one
medium to another. E.g. from a compact
disk to hard disk for faster input.
Input validation
Data entered into the computer is
subjected to validity and verification
checks before processing.
Accuracy
Timeliness
Relevance
Audibility
Accuracy
This refers to whether information/data is
accurate – true or untrue. As long as the
correct instructions and data are entered,
computers produce accurate results
efficiently.
Timeliness
This refers to whether the information is
available when it is needed, and if its outdated
when it is received or when it is used. If
information is not available when needed or
its outdated by the time its used then has little
or no value in decision making.
Relevance
The data entered must be pertinent to the
proce3ssing needs at hand and must meet the
requirements of the processing cycle.
Audibilit
y
Audit ability also refers to as verifiability.
This is the ability of users to check the
accuracy and completeness of information.
Threats to data integrity
Threats to data integrity can be minimised
through the following;
Using error detection and correction software when
transmitting data.
Design user interfaces that minimizes chances of
invalid data entry.
Using devices that capture data directly from source
e.g. scanners etc.
Control access to data by enforcing security
measures.
Back up data preferably on external storage
Data processing methods
Data can be processed using one of the
following methods.
Mechanically
Manually
Electronically
Manual data processing
In this method staff in an
organisation uses the laid
down procedures and rules to
collect data, process and
distribute information to
relevant departments for use.
The tasks are done manually
with a pen and a paper. No
machines are used to process
data instead they use simple
tools like tables and rulers.
Mechanical data processing
Mechanical systems
are those where staff
use various mechanical
machines like
calculators,
typewriters, cash
registers duplicating
machines etc to
perform operations.
Electronic data processing
In this system, data is
manipulated using electronic
machines to produce
information. This method is
faster and more accurate than
the manual and mechanical
where large volumes of data are
to be processed. This method
involves the use of computers
and other electronic machine
like mobile phones, washing
machines, modern digital TVs
etc.
Factors determining the methods of data processing
Timing aspects
Master file
Transaction file (movement file)
Reference file
Sort file
Back – up file
Report file
Master file
This is the main file that contains permanent
records about a particular item or entries. The
master file contains both static and dynamic
fields. For example a payroll system might
keep a master file containing employees
personal details (name, address, date of birth,
sex etc) which rarely change (static fields) and
data describing the earnings and deductions
which frequently change (dynamic fields).
Transaction file (movement file)
This file includes input and output files for
holding temporary incoming or outgoing
data. It contains data about an organisation
activities taking place for some period of
time. This file is used to update dynamic
data on master files.
Reference file
They are permanent or semi permanent
and are used for reference or look up
purposes. They contain records that are
fairly static. E.g. price, lists, Pay As You
Earn etc.
Sort file
These files are created from existing
transaction or master files. They are used
where data is to be processed sequentially.
Data or records are first sorted in a particular
format for example they are arranged in
ascending or descending order of the key
field and stored in the sort file.
Back – up file
These files are duplicate copies of existing
files. They are used to supplement the
operational files in case of loss by any reason.
They are created any time and update is
carried out on the master file.
Report file
They contain sets of records extracted from
data in the master files. They are used to
prepare reports that can be printed at a later
date, for example, list of absentees, overtime
etc.
File processing activities 1
Updating – refers to changing data in
master file to reflect the current status.
Referencing – happens when it is made to
particular records to ascertain what is
contained therein. The activity does not alter
the contents of master file from a file.
Sorting – this entails arranging of file
contents into some pre – determined
sequence of the key field, which occupy
the same position on the records.
File processing activities 2
Merging – the process that combines the
contents of two or more input files into one
output files.
Matching – the input files records are
matched/compared to ensure that records exist in
both the files.
Summarizing – the records of interest from the file
are accumulated to form a record in the output
file.
Searching – it entails looking for the record of
interests from the file.
File updating 1
Hit rate – hit rate is used to describe the rate
of processing of a master file in terms of its
active records. For example, if 600
transactions are processed each day against a
master file of 12,000 records, then the hit rate
is said to be 5% i.e. 600/12000*100
File updating 2
Volatility – this is the frequency with which
records are added to the file or deleted from
it. If the frequency is high, then the file is
said to be ‘volatile’ otherwise ‘static’.
Size – refers to the amount of data stored in
the file. Its expressed in terms of the total
number of records in the file.
Growth – files will always grow as new
records are added to it.
File organisation methods
File organisation is the arrangements of
records within a particular file. There are four
methods of storing files and retrieving them
from secondary storage devices.
Sequential file organisation
In this organisation records are stored and
accessed in a particular order sorted using key
field. The key field is used to search for a
particular record. Searching commences at the
beginning of the file and proceeds to the ‘tail’
of the file until the record is reached. Mainly
used with magnetic tapes.
Advantages of sequential file
Simple to understand the approach.
Easy to organise, maintain and
understand.
Reading a record requires only the key
field.
Inexpensive input/output media and
devices are used.
Disadvantages of sequential file
Entire file must be accessed even when the
activity rate is very low.
On-line processing
Time sharing processing
Real time processing
Multi-programming / multi-tasking
Distributed processing
Batch processing
Multi-processing
Interactive processing
On-line processing
In this processing the result of data
processing is available immediately. All the
computer peripherals and equipments are
under the direct control of the central
processor. As soon as the input transactions
are available, they are processed to produce
the required information. The user can
interact with the system at any time of
processing using input/output facilities.
Application of on-line processing
Banking
Stock exchange
Stock control
Water/electricity billing
Advantages of on-line processing
Bureau
Learning institutions.
Companies.
Advantages of time sharing processing
Air reservation
Hotel reservation
168
Introduction
Human beings have evolved from
the stone age to a highly
sophisticated and advanced
society by inventing things like
the wheel, fire, transistors and
today’s ultra modern devices like
computers. The idea of computers
started way back in the nineteenth
century. The first generation
computers called Electronic
Numeric Integrator And
Calculator (ENIAC 1) were
operated by plugging wires into a
control panel that resembles the
old telephone switchboards.
Computer programming
A program – is an organised list of statements
(instructions) that when executed, causes the
computer to behave in a predetermined manner or
carry out a defined task.
Programming – refers to the process of
developing computer (instructions) programs
used to solve a particular task.
A computer program – is designed using a
particular programming language. Each language
has a special sequence or order of writing
characters usually referred to as syntax.
Terms used in programming
Source program
Object code
Translator
Assembler
Interpreter
Compiler
Source program
This refers to the program code that the
programmer enters in the program editor
window that is not yet translated into
machine-readable form.
Object code
This refers to the program code that is in
machine-readable. i.e. a source code that has
been translated into machine language.
Translator
These are programs that translates/convert the
source program into object code. E.g.
assemblers, compliers, interpreters etc.
Assembler
An assembler translates a program written in
assembly language into machine language,
Interpreter
This translates the source program line- by-
line, allowing the CPU to execute one line
before translating the next. The translated
line is not stored in the computer memory,
hence every time the program is executed,
it has to be translated.
Complier
This translates the entire source program
into object code. The compiler translates
each high-level instruction into several
machine code instructions in a process
called COMPILATION and produces a
complete independent program that can be
run by the computer as often as required
without the original source program being
present.
Difference between the interpreters and compilers
Interpreters Compilers
Translates the source program Translates the entire source code
one statement at a time. at once before execution.
Translates the program each time Compiled program (object
it is run hence slower than code) can be saved on a
compiling. storage media and run as
required, hence executes
faster than interpreted
programs.
Interpreted object code takes Compiled programs require more
less memory compared to memory as the object file are
compiled program. larger.
Level of programming languages
Low-level languages.
High-level languages.
Low-level languages
These languages are classified as low because
they can be easily understood by the
computer directly or they require little effort
to translate into computer understandable
form. These languages are hardware oriented
and therefore they are not portable. i.e. a
program written for one computer cannot be
installed and used on another.
High-level languages
These languages are very close to the
human language (English-like) and they can
be read and understood even by people who
are not experts in programming. These
languages are machine independent. This
means that a programmer concentrates on
problem solving during a programming
session rather than how a machine operates.
Types of low level languages
Machine language (First generation
languages).
Delphi Pascal
Visual Cobol
C++
Fifth generation languages (5GL’s)
MERCURY
LISP
OCCAM
Object Oriented Programming Language (OOP)
Simula
Small talk
Web scripting languages
These languages are used to develop or add functionalities on web
pages. Web pages are hypertext documents created in a language
called HyperText Markup Language (HTML). The languages
consist of markup tags that tell the Internet browser that the file
contains HTML-code information and is distinguished by a file
extension of HTML. The markup tags define the various components
of a World Wide Web document such as heading, tables, paragraphs,
lists etc. HTML does not have the declaration part and control
structures, hence it’s not considered as a true programming language.
Due to its simplicity, it has many limitations and cannot be used
alone when developing functional websites. Some special blocks of
codes called Scripts may be inserted in HTML pages using
scripting languages like JavaScript, VBScript etc in order to add
functionality to HTML pages.
Examples of HTML tags and their meanings
Tag Meaning
<HTML> Marks the beginning and end of a HTML document. All other tags and text fall
</HTML> between these two tags.
<TITLE> Gives title of te web page. Text between this tags appears in the title bar when the page is
</TITLE> browsed.
<H1> Sets size of text on the web page with H6 displaying the smallest and H1 the
</H1> largest size.
Creating a script using Javascript 1
Problem definition
Program design
Program coding
Program testing
Program implemetation
Problem recognition
This refers to the understanding and
interpretation of a particular problem. To
understand a problem one has to look for key
words such as compute, evaluate, compare
etc. a programmer identifies problems in the
environment and seeks to solve them by
writing a computer program that would
provide the solution.
Circumstances that can cause the
programmer to identify a problem
Opportunity to improve the current
program.
Sequence
Selection decision
Iteration (looping) repetition
Sequence
In this control structure, the computer reads
instructions from a program file starting from
the first top line and proceeding downwards
one by one to the end. Hence sequential
program execution enables the computer to
perform tasks that are arranged consecutively
one after another in the code.
Example of how a sequential
programs code execute
The
program file
reader
reads
For example
IF <
Condition >
Then Action 1
Else
Action 2
Endif.
Example
To withdraw money using an ATM a
customer must have a balance in his/her
account.
General format of THE-WHILE DO LOOP
2. Format for the ‘For’ loop that counts from upper limit
down to lower limit
For loop variable = Upper limit Down To Lower
Limit Do
Statements
EndFor
Flowchart for a For Loop that counts upward
Statement
Flowchart for a For Loop that counts downwards
Statement
Examples of complex pseudo codes 1
Ushirika Society pays 5% interest on shares
exceeding Kshs 10,000 and 3% on shares that do
not meet this target. However no interest is paid on
deposits in the member’s bank account. Design a
pseudo code for a program that would:
a. Prompt the user for shares and deposit of a
particular member.
b. Calculate the interest and total savings.
c. Display the interest and total savings on the screen for a
particular member.
Pseudo code of examples 1
Pseudo code
Start
Input Name, share, Deposit If
share > 10000 THEN Interest
= 0.05*shares ELSE
Interest=0.03*shares
Endif
Total savings = deposits + Interest + shares
Print Name, Totalsaving, Interest
Stop
Flowchart of example 1
80 – 100 A
70 – 79
60 – 69 B
50 – 59
Below 50 C
The program should then display each student’s name, total
marks and average grade.
D
Pseudo code of example 3
Pseudo code If (AVG>60) AND (AVG<69) THEN
START Grade = ‘C’
REPEAT If (AVG>50) AND (AVG<59) THEN
Print “Enter name and subject marks” Grade = ‘D’
Input Name, maths, English, Kiswahili, ELSE
Computer, Biology Grade = ‘E”
Sum = Endif
Maths + English + Kiswahili + Endif
Computer + Biology
AVG = sum / 5 Endif
If (AVG>80) AND (AVG<100)
THEN
Endif
Grade = ‘A’
Print
If (AVG>70) AND (AVG<79) Nam
Stop
THEN
Flowchart of example 3
Practical activity 1-1
1. Open a text editor program on your computer like NotePad or
WordPad.
2. Type the following program exactly the way it is in the editor.
<HTML>
<HEAD><TITLE>This is my first a webpage</TITLE></HEAD>
<BODY bgcolor = “red”>
<H1><CENTER><B>Hello World</B></CENTER></H1>
</BODY>
</HTML>
3. Save your work as webpage.html on the desktop. Make sure that
the Save As Type box reads “All Files” before clicking the save
button in order to avoid saving a text file with two extensions i.e.
webpage.html.txt.
Practical activity 1-2
4. Close your text editor. Notice that
your file on the desktop has the
icon of the default web browser
installed on your computer.
Double click it to view the web
page! Figure right shows a
sample of the display expected
when the file is loaded to the
browser. If you have a colour
monitor, it should look as below
only that it will have black bold
text on a red background!
5. Check your program and change
your background to blue, save
then click the refresh button.
What happens?
Review questions 1
1. Define the term computer program.
2. What is programming?
3. State three advantages of high level languages over low level languages.
4. List four examples of languages and for each, state its most appropriate
application area.
5. Why is an executable file unique when compared to any other file?
6. Differentiate between a compiler and an interpreter. Why did early
computers work well with interpreters?
7. List the various examples of programming languages per generation.
8. State one advantage of machine language over the other languages.
9. Write the following in full
A) HTML
B) OOP
10. Distinguish between source program and object code in programming.
11. Define the term encapsulation as used in object oriented programming.
Answer of review questions 1-1
1. A computer program is a set of instructions that directs a computer on how to
process a particular task.
2. Programming is the writing of computer programs.
3. A). Easier to learn and use.
B) Portable.
C) Flexible.
D) Easier to
correct
errors.
4. A).
FORTRAN –
used for
developing
business
oriented
programs.
Answer of review questions 1-2
7. A). First generation – machine languages.
B) Second generation – assembly languages.
C) Third generation – Pascal, C, COBOL, BASIC, FOTRAN, Ada
etc.
D) Fourth generation – Visual Basic, Delphi Pascal, Visual COBOL etc.
E) Fifth generation languages – PROLOG, Mercury, LISP, OCCAM
etc.
8. A). The processor executes them faster. B).
They are more stable.
9. A). HTML – Hypertext Markup Language.
B). OOP – Object Oriented Programming
language
10. Source program refers to a program that is not yet translated while
object code refers to the program code that is in machine readable form.
11. Encapsulation refers to the process of joining data and instruction
together to form an object.
Review questions 2
1. Give one advantage of compiling a program
rather than interpreting it.
2. Outline at least six stages of program
development in their respective order.
3. Highlight two advantages of monolithic
programs.
4. State two advantages of modular
programming.
5. In what stage of the development does program
documentation fall? Justify your answer.
6. Differentiate between a flowchart and pseudocode.
7. What is a program bug?
Answer of review questions 2-1
1. A). Interpreters translate the source program one statement at a time
while compilers translate the entire source code at once before execution.
B)Interpreters translate the program each time it runs hence slower than
compiling. Compiled programs can be saved on a storage media.
This means that it does not require any further transaction every time
the program is run hence executes faster than interpreted programs.
C) Interpreters translation takes less memory while compiled
programs require more memory as the object code files are larger.
2. A). Problem recognition.
B). Problem definition.
C). Program design.
D) Program coding.
E) Program testing and debugging. F).
Implementation.
Answer of review questions 2-1
3. A). They are difficult to test and debug. B).
They are difficult to modify or upgrade.
4. A). They are easy to test and debug.
B). They are easy to modify and upgrade.
5. Documentation is done at all stages of program
development.
6. A flowchart is a graphical representation of step-by- step
processing logic of a program while a pseudocode is a set of
structured-English like statements that describe the step-by-
step processing logic of a program.
7. Bugs refers to program errors.
8. To correct any syntax or logical errors.
Review questions 3
1. State the factors you would consider when
A) Writing a pseudocode
B) Drawing a flowchart
2. Using illustrations, explain at least six symbols used in
flowchart design.
3. Give one advantage of pseudocodes over flowcharts.
4. Write a pseudocode for a program that would be used to
solve the equation
E = MC2
5. Draw a flowchart that would be used to classify animals
according to sex. If a letter M is input the program should
display ‘Male’ otherwise it should display ‘Female’.
Answer of review questions 3-1
1. A). Pseudocode 2. Decision – used to represent a
1)Statements must be short and decision construct.
clear.
2)Statements should be Connector – connects logic
unambiguous. flows.
3)Should shoe start and stop. 4).
Words used should be suggestive Process – indicates a
such as READ, transformation of data.
PRINT, OUTPUT etc.
B). Flowchart Input/output – shows
1). A flowchart should have program input/output.
one entry and one exit point.
2). Use correct symbols.
Ellipse – indicates start/stop of
3). The flow should be clearly algorithm.
indicated using arrows.
Answer of review questions 3-2
3. Pseudocodes are
easier to write and
understand.
4. Start
Enter values form
M and C
E=M*C*C
Display E
Stop
Review questions 4
1. Define the term selection in relation to program
control structures.
2. State three types of control structures used in
programming.
3. Differentiate between looping and selection.
4. In what circumstance does looping depend on
decision?
5. List four selection controls used in writing a
program.
Answer of review questions 4
1. Selection refers to a situation where further program execution
depend one making a decision from two more alternatives.
2. Sequence, decision and iteration.
3. Looping refers to a situation where the same block of code is
executed repeatedly until a certain condition is fulfilled, while
selection refers to a situation where further program execution
depends on making a decision from two or more alternatives.
4. Looping may depend on decision if a condition has to be met
before the looping terminates or continues.
5. A). IF…THEN
B) IF….THEN…ELSE
C) Nested IF D).
Case
Revision questions 1
1. State three reasons why high level languages are better than low level
languages.
2. Explain why HTML is not true programming language.
3. List three examples of forth generation programming languages.
4. Describe the term structured programming.
5. Define the term structured programming.
6. A) State two reasons for documenting all the
stages of program
development.
B)Give three types of program documentation in reference to
7. programming.
Write HTML code that would display a green background, with the words
8. ‘Hello’ on the screen.
A)DrawThea nested
flowchart showing the general flow of the following:
IF selection.
B) The FOR loop.
C) REPEAT….UNTIL loop.
Answer of revision questions 1-1
1. A). They are portable
B). They are user friendly C).
They are more flexible D).
They are easier to debug
2. HTML is not a true programming language because it does not have a true
format of a programming language. For example, it does not have a
declaration part and control structures.
3. A). Visual Basic
B). Delphi Pascal
C). Visual COBOL
4. Fifth generation programming languages are designed in a way that
enables programmers design programs that emulate human intelligence.
5. In structured programming, a program is broken down into
components called modules each performing a particular task.
Answer of revision questions 1-2
6. A). Reasons for documenting
i. There may rise a need to revise or modify it.
ii. Other people may think of ways of improving your program by
studying at the documentation.
B) Types of documentation
i. User-oriented.
ii. Operator-oriented.
iii. Programmer-oriented.
7. <HTML>
<HEAD><TITLE>Hello program </TITLE></HEAD>
<BODY bgcolour = “blue”>
<H3><CENTRE><B>Hello</B></CENTER></H3>
</BODY>
</HTML>
Answer of revision questions 1-3
Answer of revision questions 1-4
Revision questions 2
1. Write a program algorithm that would enable the user to
enter student marks. The program should then determine
whether the mark entered is a pass or fail given that the
pass mark is 50.
2. Draw a flowchart for a program that is to prompt for N
numbers, accumulate the sum and then find the average.
The output is the accumulated totals and the average.
3. Write a pseudocode that reads temperature for each day in
a week, in degree Celsius, converts the Celsius into
Fahrenheit's and then calculate the average weekly
temperatures. The program should output the calculated
average in degrees Fahrenheit's.
Answer of revision questions 2-1
Answer of revision questions 2-2
3. START
Input temperature in ℃
et initial day to 0
WHILE initial day 6 DO
Input temperature in ℃
F=32+(9C/5)
Initial day=initial day + 1
Cummulative = cummulative + F
END WHILE
Average weekly temperature
= cummulative/7
Print Average
STOP
Revision questions 3
1. A lady deposits 2,000 shillings in a Microfinance company
at an interest rate of 20% per annum. At the end of each
year, the interest earned is added to the deposit and the new
amount becomes the deposit for that year. Write an
algorithm for a program that would track the growth of the
deposits over a period of seven years.
2. Mukumu took a loan of Ksh 400,000 from a local bank at
an interest rate of 10% payable in four years. Assuming
you wish to develop a computer program that will keep
track of monthly repayments:
A) Identify the input, processing and output
requirements for such a program.
B) Design the algorithm for the program using a simple
flowchart and pseudocode.
Answer of revision questions 3-1
1. START
Input initial deposit
Input interest rate
Set deposit to initial deposit
Set year to 0
WHILE year < 7 DO
Interest = Deposit *
interest rate
Total = Deposit + interest
Deposit = Total
Year = Year + 1
END WHILE
PRINT Deposit, Year
STOP
Answer of revision questions 3-2
2. A).
Inputs – initial amount borrowed
- Interest rate
- Number of years
Processing – the equation to calculate
monthly repayments.
Output – monthly repayments calculated by
the process
Answer of revision questions 3-3
2. B).
START
Input initial loan borrowed
Input interest rate Input
number of years
Calculate yearly
repayments Monthly
repayments
= yearly repayments/12
Display monthly
repayments
STOP
Chapter
System
4 development
289
A system
Is a set of items linked together to carry out a
given task in order to achieve one or more
objectives. A system is described as being
either soft or hard.
Soft systems and hard systems
Soft systems – human activity are said to be soft
systems. They are said to be soft because:
Their boundaries may be fluid or keep on changing.
Their goals and objectives conflict.
It’s difficult to precisely define exact measures of
performance for them.
Hard systems – these are systems whose goals and
objectives are clearly defined and the outcomes
from the systems processes are predictable and
can be modeled accurately.
System classification
Deterministic system – these are systems whose
output are known precisely by their inputs e.g. a
computer system.
Probabilistic system – these are systems whose
output can only be predicted but not knows
precisely e.g. business and economic system
organisation.
Cybernetic systems – these are self controlling
systems which adapt to the environment and
regulate their own behaviour by accessing the
feedback. They access their output and adjust the
input e.g. human beings, plants systems
Characteristic of systems
1. Holistic thinking 7. Interdependence
2. Sub systems 8. Feedback
3. Processor 9. Control
4. Objectives/purpose 10. Inputs and Outputs
5. Environment 11. System Entropy
6. Boundaries
Holistic thinking and sub systems
Holistic thinking – in this, a system is considered as
a whole. A combination of various components that
makes up a system creates a complex whole whose
overall goals are more sophisticated than those of
the individual components.
Traditional Approach.
Record inspection
Interview
Questionnaires
Record inspection and interview
The documents maintained in
connection to the system are
referenced. This forms a good
starting point for the analyst to
gain an overall insight of the
existing system.
Interview – this is a face to
face communication between
the analysts as the interviewer
and the affected personnel as
interviewee. The questions are
geared to getting the
information needed by the
analysts.
Advantages of interview
The analysts is accessible to first class
information.
Output specification
Input specification
File/data stores
Hardware and software requirements
Output specification
The output specifications entails activities
like generation of reports used to facilitate
decision making. The output can be in the
form of reports either in hardcopy or
softcopy. The quality of those reports is
important. Formality of reports is important
so that good quality reports are produced for
easy understanding.
Input specification
The input to the system in necessary because
the contents of the input are used to maintain
the master files. The following should be
considered in input specification.
Type of changeover
Direct changeover
Parallel changeover
Phase changeover
Direct changeover
In this approach the new system commence live
operation and immediately the old system is
abandoned.
356