Computer System Programming
Computer System Programming
COMPUTER
PROGRAMMING
System Software are designed to control the operation and extend the processing
functionalities of a computer system. System software makes the operation of a
computer more fast, effective, and secure. Example: Operating system,
programming language, Communication software, etc.
System software serves as the interface between hardware and the end users.
Examples are:
Operating System
Utility Software
Computer Language Translator
Features of System Software are as follows:
Close to system
MICROSOFT
WORD
SOFTWARE
SPREADSHEET
PACKAGE
SYSTEM APPLICATION
SOFTWARE SOFTWARE
DATABASE
PACKAGE
OPERATING UTILITY COMPUTER
SYSTEM SOFTWARE LANGUAGE
TRANSLATOR GRAPHICS
PACKAGE
SINGLE MULTI
USER USER STRUCTURAL/
ARCHITECTURAL
PACKAGE
MAINTENANCE
TASK
CUSTOMIZED
PACKAGE
A. OPERATING SYSTEM
i. An operating system is a program that acts as an interface between the software
and the computer hardware.
ii. It is an integrated set of specialized programs that are used to manage overall
resources and operations of the computer.
iii. It is specialized software that controls and monitors the execution of all other
programs that reside in the computer, including application programs and other
system software.
TRANSLATOR
The main objective of a translator is to convert a set of instruction or program
written in high level language into an equivalent program in machine readable form
via one or more intermediate language.
Types of translator are:
Compiler: This is also a convertor which converts whole high level language
programme to low level language programme at a time.
C. Utility Software
Utility programs tend to perform specific tasks related to the management of
hardware. Examples of utility programs include compression programs, formatters,
defragmenters and other disk management tools.
Concept of programming
System development cycle
Stages of program development
Features of a good computer program
CONCEPT OF PROGRAMMING
A program is a set of instructions that tells the computer what to do. Computer
programming (often shortened to programming or coding), is the process of
writing, testing, debugging/troubleshooting and maintaining act of instructions
(source code) for solving a problem with the computer. A source code is written in
an acceptable computer programming language. The code may be a modification
of an existing source or something completely new.
2. Write the steps of computation that are necessary to arrive at the solution.
This is setting up the algorithm.
8 | Page INTRODUCTION TO COMPUTER PROGRAMMING-AKILAPA,
B.O
3. Prepare a flowchart corresponding to the algorithm.
4. Develop the computer program. Test and run it on the computer. There
is an ongoing debate on the extent to which the writing of programs is an art,
Once the users start using the new system, they will often suggest new
improvements and the whole process is started all over again.
These are methodologies for defining a systems development cycle and often you
will see four key stages, as listed below.
Programming Design
1. Reliability
Any developed program for a particular application can be depended upon to
do what it is supposed to accomplish. How often the results of a program are
correct. This depends on prevention of resulting from data conversion and
prevention of errors resulting from buffer overflows, underflows and zero
division.
2. Meeting Users Needs: Any developed system has a purpose for which it is
developed. A developed program is a failure if it cannot meet the objectives
for which it is proposed and designed, that is, if the potential users cannot
use it either because it is too complex or too difficult. The usability of an
application analysis involving the user.
3. Development on time within Budgets: Estimates of time and cost for
writing computer programs have frequently been under or over estimated.
The components of a structured disciplined approach to programming are:
Proper control and management of
time and cost required.
Increased programmer productivity
More accurate estimates.
4. Error-Free Set of Instruction
Almost all large set of programs contain errors. If a program is designed and
developed in a disciplined structured approach, it minimizes the likelihood of
errors and facilitates detection/correction of such errors during program
testing.
Definition of Algorithm
Features of an Algorithm
CONCEPT OF ALGORITHM
An algorithm is a set of instructions to obtain the solution of a given problem.
Computer needs precise and well-defined instructions for finding solution of
problems. If there is any ambiguity, the computer will not yield the right results.
It is essential that all the stages of solution of a given problem be specified in
details, correctly and clearly moreover, the steps must also be organized rightly so
that a unique solution is obtained.
Features of an Algorithm
1. It should be simple
2. PSEUDO CODE
A pseudo code is the English-like representation of the program logic. It does not
make use of standard symbols like the flowchart. It is a sequential step by step
3. FLOWCHART
Flowchart is a representation of the algorithm using standard symbols. Each
symbols has a new function. The Algorithm steps determine which symbol to use
to represent it in the flow each step is linked to another step by using the
directional arrows. A flowchart is a pictorial representation of an Algorithm or of
the plan of solution of a problem. It indicates the process of solution, the relevant
operations and computations, point of decision and other information that are part
of the solution. Flowcharts are of particular importance for documenting a
program. Special geometrical symbols are used to construct flowcharts. Each
symbol represents an activity. The activity could be input/out of data,
computation/processing of data, taking a decision, terminating the solution, etc.
The symbols are joined by arrows to obtain a complete flowchart.
EXAMPLE 1
Draw a flowchart to find the average of four numbers stored in variables A,B,C,D
Read numbers in
A,B,C,D
Stop
EXAMPLE 2
Draw a flowchart to find the average of four numbers stored in variables A,B,C,D.
when the value of A is zero, no averaging is to be done.
SOLUTION
Star
t
READ values
For A,B,C,D.
Is
A=0
?
Calculate the
average
Stop
Start
INPUT L, B
AREA = L * B
PRINT L, B,
AREA
END
EXAMPLE 4
Write an algorithm and draw a flowchart that will read the two sides of a rectangle
and calculate its area.
SOLUTION
Pseudo code
Step 1: Input W, L
Step 2: A= L * W
Step 3: Print A.
Flowchart
Stop
Input
W,L
A = L*W
Print A
Stop
FLOWCHART
Start
Input
a, b, c
d = Sqrt + (b * b – 4*a*c
X1
25 | P a g e INTRODUCTION TO COMPUTER PROGRAMMING-AKILAPA,
B.O
(
Print
X1, X2
= ( - b + d)/ (2*a)
X2 = - b – d) / (2* a)
Stop
EXAMPLE 6
Draw a flowchart that would compute the area of a triangle, given the base as B
and height H
SOLUTION
Start
INPUT B, H
AREA = 1/2B * H
PRINT B, H
AREA
USES OF FLOWCHARTS
Flowchart Advantages
Flowcharts are easier to understand compare to Algorithms and Pseudo
code.
It helps us to understand Logic of given problem.
It is very easy to draw flowchart in any word processing software like MS
Word.
Using only very few symbol, complex problem can be represented in
flowchart.
Flowcharts are one of the good way of documenting programs.
It helps us in debugging process.
Flowchart Disadvantages
Manual tracing is needed to check correctness of flowchart drawn on paper.
Simple modification in problem logic may leads to complete redraw of
flowchart.
Showing many branches and looping in flowchart is difficult.
In case of complex program/algorithm, flowchart becomes very complex and
clumsy.
27 | P a g e INTRODUCTION TO COMPUTER PROGRAMMING-AKILAPA,
B.O
Modification of flowchart is sometimes time consuming
Each of the high-level languages has rules that govern how to write instructions in
them. Like any human language, it is the duty of the programmer or user to learn
the rules of the language he wants to use.
The example below shows how to add two numbers held in variables X and Y
placing the sum in X using the most common four high-level languages.
BASIC……. LET X = X + Y
COBOL………. ADD Y TO X
PASCAL…….. X: = X + Y
It can be observed that the notation is very similar to human ways of thinking and
expression and very remote from the machine language.
TYPES OF PROGRAMMING
Procedural Programming
Procedural Programming can be defined as a programming model which is derived
from structured programming, based upon the concept of calling procedure.
Procedures, also known as routines, subroutines or functions, simply consist of a
series of computational steps to be carried out. During a program’s execution, any
given procedure might be called at any point, including by other procedures or
itself. Languages used in Procedural Programming: Q-BASIC, FORTRAN,
COBOL, BASIC, Pascal and C.
To save:
To go back to the coding screen, obey the instruction: ‘Press any key….’
5 CLS
10 REM
15 Print “BIO-DATA Quiz”
20 Print “_____________”
25 Print “He was born and brought up in Lagos.”
30 Print “He hails from Kwara.”
35 Print “He settles down in Ondo.”
40 Print
45 Print “Who is He?”
50 END
5 CLS
10 REM
15 INPUT birthyear
20 INPUT currentyear
25 PRINT currentyear-birthyear
30 END
INPUT STATEMENT
These are statements that are used for feed/supply data unto the computer
system.
Two Types:
Input Method
Read & Data Method
INPUT Method
SOLUTION (i)
5 CLS
10 REM
15 INPUT “Enter value for A: ”, a
43 | P a g e INTRODUCTION TO COMPUTER PROGRAMMING-AKILAPA,
B.O
20 INPUT “Enter value for B: ”, b
25 INPUT “Enter value for C: ”, c
30 Let F = ((b^2) / (4*a*c))
35 PRINT “The answer is: ”, F
40 END
Here there is no need using INPUT to enter the value of A because it is already
given.
Programming Example
Given: t = 15, u = 210, s = 14, r = 11
Code in QBasic to compute:
1. V = t + (u – r)
2. W = u/ t2 + s3/t2
Solutions
5 CLS
Solutions
5 CLS
10 REM
15 READ u, s, t
20 DATA 210, 14, 15
30 Let W = ((u/(t^2)) + ((s^2)/(t^2)))
35 PRINT “The answer is: ”; W
40 END
SOLUTION
10 REM PROGRAM AREA OF A RECTANGLE
15 INPUT L, B
20 AREA = L * B
25 PRINT B, H, AREA
30 END
EXECRISE II
Write a QBASIC program to compute the area of a triangle, given that the base B
and the height H.
SOLUTION
10 REM PROGRAM AREA OF A TRIANGLE
15 INPUT B, H
20 AREA = (B/H)/2
25 PRINT B, H, AREA
30 END
47 | P a g e INTRODUCTION TO COMPUTER PROGRAMMING-AKILAPA,
B.O
EXECRISE III
Write a QBASIC Program that would compute the sum and average of any four
numbers, print the sum as well as the average.
SOLUTION
10 REM PROGRAM TO SUM AND AVERAGE FOUR NUMBERS
15 CLS
20 INPUT “ENTER THE FOUR NUMBERS”, A,B,C,D
25 SUM = A+B+C+D
30 AVG = SUM/4
35 PRINT “SUM = “; SUM; “AVERAGE = “; AVG
40 END
ASSIGNMENT
1. Write a QBasic program that inputs your scores in ACC101, ACC103 and ACC105.
Computes:
1. Their Sums
2. Their Average
2. Draw a flowchart and write a QBASIC program for adding the integers 1 to 50
and producing their average
There are three primary steps involved in building a visual Basic application.
1. Draw the user interface by placing controls on the form.
2. Assign properties to controls.
3. Attach code to control events (and perhaps write other procedures)
Note:
1. These same steps are followed whether you are building a very simple
application or one involving many controls and many lines of code.
2. The event – driven nature of visual Basic allows you to build your application
in stages and test it at each stage. You can build one procedure, or part of
a procedure, at a time and try it until it works as descried. This minimizes
errors and gives you, the programmer, confidence as your application takes
shape.
3. As you progress in your programming skills, always remember to take above
sequential approach to building a visual Basic application Build a little, test a
little, modify a little and test again. You will quickly have a completed
application.
Microsoft VB is the fastest and easiest way to create applications for
Microsoft windows.
The visual part refers to the method used to create the graphical user
interface (GUI).
The Basic part refers to the BASIC Beginners All – Purpose symbolic
construction code Language.
Fig
ure 1.2: VB6 Programming Environment
The Form is the primary building block of a Visual Basic 6 application. A Visual
Basic 6 application can actually comprise many forms, but we shall focus on
developing an application with one form first. We will learn how to develop
applications with multiple forms later. Before you proceed to build the application,
it is a good practice to save the project first. You can save the project by