Introduction To Programming Handout
Introduction To Programming Handout
LECTURE NOTE
ON
CHAPTER ONE
INTRODUCTION TO SYSTEM PROGRAMMING
1
COMPUTER SYSTEMS
A Computer is an electronic device that stores, manipulates and retrieves the data. A
System is a group of several objects with a process. For Example: Educational System involves
teacher, students (objects). Teacher teaches subject to students i.e., teaching (process).
COMPUTER HARDWWARE
Hardware of a computer system can be referred as anything which we can touch and feel.
Example: Keyboard and Mouse.
CPU
INPUT OUTPUT
Primary memory: The following are the types of memories which are treated as primary
1. ROM: It represents Read Only Memory that stores data and instructions even when the
computer is turned off. The Contents in the ROM can‘t be modified once if they are written.
It is used to store the BIOS information.
2. RAM: It represents Random Access Memory that stores data and instructions when the
computer is turned on. The contents in the RAM can be modified any no. of times by
instructions. It is used to store the programs under execution.
3. Cache memory: It is used to store the data and instructions referred by processor.
2. Optical Storage: The optical storage devices that use laser beams to read and write stored data.
Example: CD(Compact Disk),DVD(Digital Versatile Disk)
COMPUTER SOFTWARE
Software is a set of instruction given to the computer to perform a certain task. Software
comprises of the entire set of programs, procedures and routines associated with the operation of a
computer system. Example: Windows, icons
Computer software is divided in to two broad categories: system software and application
software.System software manages the computer resources .It provides the interface between the
hardware and the users. Application software, on the other hand is directly responsible for helping
users solve their problems.
1. SYSTEM SOFTWARE
3
System software consists of sequence set of instructions designed for the computer to carry
out a given task. Also, it’s a programs that manage the hardware resources of a computer and
perform required information processing tasks.
They are specialized programs usually written by computer manufacturer which were
developed with the aim of ensuring optimal utilization of all the computer system resources such
as processors, main memory, peripherals and files as well as to simplify the use of the entire
computer system in solving problems in such a way that the ordinary person can translate. These
programs are divided into three classes: the operating system, system support, and system
development.
The operating system provides services such as a user interface, file and database access, and
interfaces to communication systems such as Internet protocols. The primary purpose of this
software is to keep the system operating in an efficient manner while allowing the users access to
the system.
a) System support software provides system utilities and other operating services. Examples of
system utilities are sort programs and disk format programs. Operating services consists of
programs that provide performance statistics for the operational staff and security monitors to
protect the system and data.
b) The last system software category, system development software, includes the language
translators that convert programs into machine language for execution, debugging tools to
ensure that the programs are error free.
2. APPLICATION SOFTWARE
Application software is a program written to solve user problems. They may be developed
by users themselves or by a computer manufacturer or special software houses e.g employee’s
records in a company and application packages. Application software is broken into two classes:
i. General – Purpose Software: is a software purchased from a software developer and can be
used for more than one application. Examples of general purpose software include
Microsoft office, database management systems e.t.c. They are labeled general purpose
because they can solve a variety of user computing problems.
4
ii. Application–Specific Software: is a software customized/designed to meet the needs of
particular application such as automated weather stations, typically to be used by end-users
e.g. Media player, Accounting software e.t.c
2. They were developed to ensure optimal They were developed to solve user problems
utilization of all computer resources such as in a standardized or generalized ways
memory, processor, peripherals and input/output
devices
1. Language Translator: These are programs which translate programs written in non-
machine language (Fortran, Cobol, Visual Basic e.t.c) into the machine languages
equivalent examples of language translators are Compiler, Assembler and Interpreter.
3. Database Management System: This is a complex program that is used for the creation,
storage, retrieval and maintenance of a database as well as providing security on the
database. A database can be described as or collection of related data relevant to the
operations of a particular organization. These data are stored usually in a central location
and can be assessed by different authorized users.
CHAPTER TWO
COMPUTING ENVIRONMENTS
The word “compute” is used to refer to the process of converting information to data. The advent
of several new kinds of computers created a need to have different computing environments.
TIME-SHARING ENVIRONMENT
The concept of time sharing computing is to share the processing of the computer basing on the
criteria time. In this environment all the computing must be done by the central computer.
The complete processing is done by the central computer. The computer which ask for processing
are only dumb terminals.
6
CLIENT/SERVER ENVIRONMENT
A Client/Server Computing involves the processing between two machines. A client
Machine is the one which requests processing. Server Machine is the one which offers the
processing. Hence the client is Capable enough to do processing. A portion of processing is
done by client and the core (important) processing is done by Server.
DISTRIBUTED COMPUTING
A distributed computing environment provides a seamless integration of computing functions
between different servers and clients. A client not just a requestor for processing the information
from the server. The client also has the capability to process information. All the machines
Clients/Servers share the processing task. Example: Ebay on Internet
7
8
CHAPTER THREE
PROGRAMMING LANGUAGES
Programming Languages are notational system for communication with computer. There
are three categories of programming language: Machine Language, Low-Level Language and
High-Level Language.
To write a program (tells what to do) for a computer, we must use a programming
language. Over the years computer languages have evolved from machine languages to natural
languages.
MACHINE LANGUAGE
In the earliest days of computers, the only programming languages available were machine
languages. Each computer has its own machine language which is made of streams of
0‘s and 1‘s. The instructions in machine language must be in streams of 0‘s and 1‘s. This is also
referred as binary digits. These are so named as the machine can directly understood the
programs
ADVANTAGES:
1. High speed execution
2. The computer can understood instructions immediately
3. No translation is needed.
DISADVANTAGES:
1) Machine dependent
2) Programming is very difficult
3) Difficult to understand
4) Difficult to write bug free programs
9
5) Difficult to isolate an error
Example Addition of two numbers
2 0010
+ 3 0011
--- ---------------
5 0101
--- ---------------
LOW-LEVEL LANGUAGE
In the early 1950‘s Admiral Grace Hopper, a mathematician and naval officer, developed
the concept of a special computer program that would convert programs into machine language.
These early programming languages simply mirrored the machine languages using symbols or
mnemonics to represent the various language instructions.
These languages were known as symbolic languages. Because a computer does not
understand symbolic language it must be translated into the machine language. A special program
called an Assembler translates symbolic code into the machine language. Hence they are called as
Assembly language.
ADVANTAGES:
1) Easy to understand and use
2) Easy to modify and isolate error
3) High efficiency
4) More control on hardware
DISADVANTAGES:
10
HIGH-LEVEL LANGUAGES
The symbolic languages greatly improved programming efficiency they still required
programmers to concentrate on the hardware that they were using working with symbolic
languages was also very tedious because each machine instruction had to be individually coded.
The desire to improve programmer efficiency and to change the focus from the computer to the
problems being solved led to the development of high-level languages. High-level languages are
portable to many different computer allowing the programmer to concentrate on the application
problem at hand rather than the intricacies of the computer.
ADVANTAGES:
1) Easy to write and understand
2) Machine independent language
3) Easy to maintain
4) Better readability
5) Easier to document
6) Portable
DISADVANTAGES:
1) Needs translator
2) Requires high execution time
3) Poor control on hardware
11
Languages Only one Different Manufacturer Different Languages
Nature Difficult Difficult Easy
Memory Space Less Less More
12
CHAPTER FOUR
LANGUAGE TRANSLATORS
A language translator is a program that translate or convert a program in a non-machine
language to machine language equivalent. The function of a translator is t check for the syntactic
and sematic correctness of statements in a program. This is generated before the actual conversion
into the machine language which the computer understand. These are the programs which are
used for converting the programs in other language into machine language instructions, so that
they can be executed by the computer.
1. ASSEMBLER:
It is a program which is used to translate the assembly oriented language programs into
machine language. It is a program that translate a user program or source program written with
mnemonics into a machine language programs which the system can execute.
The process of translation is called Assembly while the time of assembly is called Assembly
Time.
TYPES OF ASSEMBLER
a) One-Pass Assembler: This is an assembler that performs all its functions by reading the
source code once and the execution began with the computer.
b) Two-Pass Assembler: it reads the source code twice before execution
c) Cross Assembler: it is an assembler that runs on a computer and assembles programs for
another. They are mostly written in high level language and later run to produce object code.
13
d) Dis-Assembler: this is the opposite of an assembler, it translate object code to source code in
an assembly language.
FUNCTIONS OF ASSEMBLER
a) It convert mnemonics operation codes to their machine language
b) It convert symbolic operands to machine language
c) It decides the proper instruction format in programming
d) It write source programs and convert to machine code equivalent
e) Deletion and printing of errors found in source program e.g. invalid, wrongly spelled
operation code
2. COMPILER:
It is a program which is used to convert the high level language programs into machine
language.The input to a compiler, called a source program is a program written in HLL. The
output of a compiler is called an object program which is the machine equivalent of the source
program.
TYPES OF COMPILER
a) Single-Pass Compiler: This is a compiler that passes through the source code of each
compilation unit only once. In other words, a single-pass compiler does not “look back” at
code it previously processed
b) Multi-Pass Compiler: This type of compiler transverses the source code several times,
building one or more intermediate representations that can be redefined. It generate efficient
programs due to the rechecking scope available.
14
PHASES OF COMPILATION PROCESSES
In compilation of a source program into a program four main phases are involved. They are
lexical analysis, syntax analysis, semantic analysis and code generation.
i. LEXICAL ANALYSIS: The lexical analysis (scanner) is responsible for breaking down of
the source program into smallest units called Token. E.g Keywords, special characters e.t.c
from left to right. Then send each token in its internal representation form to the next phase. It
is also responsible for grouping individual symbols of the source program intotheir logical
entities to detect errors.
ii. SYNTAX ANALYSIS: The syntax is involved in grouping the token of the source program
into grammatical phrases that are used by the compiler to produce output. It perform syntactic
checks on the source program statement i.e to ensure that the rules governing formation of the
program language are confirmed with.
For instance let’s consider the sentence “The small boy kick the ball” the knowledge of
English shows that it is a sentence of a language which can be represented using a sentence
diagram called a syntax tree.
(Sentence)
(Subject) (Predicate)
(Article) (Noun)
The Ball
15
iii. SEMANTIC ANALYSIS: This is responsible for type checking i.e. integer, real, if, end e.t.c.
It check for the meaning of a syntactic used e.g. checking that every if-statement, Do-
statement has corresponding matching statement respectively. It break complex statement into
simple form, it creates intermediates form of source program for every recognized statement
using either in parse tree e.t.c
iv. CODE GENERATION: This is the actual translation of the source program into the
machine language or assembly language. Storage is also allocated to all variables with code
generation. It provide code to improve efficiency in term of storage and execution time.
3. INTERPRETER:
It is a program, it takes one statement of a high level language program, translates it into
machine language instruction and then immediately executes the resulting machine language
instruction and so on. This is a program that does the translation and execution. The use of
interpreter ordinarily results in relative slow program because interpreted language tends to
require extensive simulation in operation. FORTRAN, PASCAL and COBOL are commonly
compiled.
1. A Compiler is used to compile an entire program An interpreter is used to translate each line of
and an executable program is generated through the program code immediately as it is entered
the object program
2. The executable program is stored in a disk for The executable program is generated in RAM
future use or to run it in another computer and the interpreter is required for each run of
the program
3. The compiled programs run faster The Interpreted programs run slower
4. Most of the Languages use compiler A very few languages use interpreters.
5. The execution time of a compiled program is less The execution time of an interpreted language is
usually more
CHAPTER FIVE
16
FLOWCHART
Flowchart is a diagrammatic representation of an algorithm. Flowchart is very helpful in
writing program and explaining program to others. It is a picture of the steps of process in
sequential order, it can be used to describe wide varieties of processes.
flowchart.
17
Draw flowchart to find the largest among three different numbers entered by user.
18
CHAPTER SIX
UTILITIES AND LIBRARY
UTILITIES
Utilities routines are part of the system, software provided with a computer to carry out
standard data processing operations. They are designed to aid program development and testing.
They are normally supplies by manufacture either as part of overall system purchased or to carry
put some requirement of a later data.
Utilities also called service programs. The common types of utility programs are Sort,
Editor, file copy, dump, file maintenance and debugging aids.
LIBRARIES
The library can simply be referred to as a place where disk are kept or a collection of
macros or other programs kept on magnetic devices such as disk or tape. It could be used to store
all disk packs used in system installation.
The library require some sort of fle security to guard against losing vital information. The storage
devices re highly sensitive and their damage may cause loss to the whole computer system.
Programs
What are utility software’s?
(i)Utility software refers to set
of programs that help to
manage, maintain and control
computer resources. Operating
systems typically contain the
necessary tools for this,
20
but separate utility programs can
provide improved functionality.
(ii)Utility programs are system
software’s used for the
management of computer
systems
and also perform maintenance
type’s tasks.
Categories of utility programs
Utility programs can be broadly
categorized into four categories
namely:-
oSystem Utilities
oFile Management Utilities
21
oStorage Device Management
Utilities
oMiscellaneous Utilities
24
CHAPTER SEVEN
OPERATING SYSTEM
An Operating System (OS) is an interface between a computer user and computer
hardware. An operating system is a software which performs all the basic tasks like file
management, memory management, process management, handling input and output, and
controlling peripheral devices such as disk drives and printers.
The Software is the Non-Touchable Parts of the Computer , and Software’s are those
which are used for Performing an Operation So that Software’s are just used for Making an
Application but hardware’s are those which are used for Performing an Operation.
1. It manages the hardware and software resources of the computer system: These
resources include the processor, memory, disk space, etc. The first task is very important i.e.
managing the hardware and software resources, as various processes compete to each other
for getting the system unit time and memory space to complete the task. In this regard; the
operating system acts as a manager to allocate the available resources to ‘satisfy the
requirements of each process.
2. Operating System also manages the Computer Memory that is provided to the process.
3. It is behaves like an extended machine that provides us sharing of files between multiple
users.
4. It performs Many Functions that’s why we can say that Operating System is a Mastermind.
5. Is a collection of programs those are responsible for the execution of other programs.
25
6. Operating system is that which responsible is for controlling all the input and output devices
those are connected to the system.
7. Operating system is that which responsible is for running all the application software’s.
8. Operating system is that which provides the communication between the user and the system.
There are different types of operating system those are organized by their Working.
1. Batch Processing: In batch processing a similar type of jobs prepared and processed.
multi-programming: in multi programming operating system multiple programs are executed
on the system at a time. In this system only one programming language can run at the same
time and the management of memory is quite necessary. Each job must be completed before
the commencement of the next.
2. Real Time System: Real Time System are used there Requires higher and Timely Response.
It is essential for computerized process control for example, in chemical production; such
activities require continual control so that parameters of pressure and temperature are adhered
to.
3. Distributed Operating System: In this operating system data is stored and processed on
multiple locations. Its and operating system that spreads the processing task of an
organization across several computer systems in most cases, these systems are connected and
share resources such as files (Banking System).
4. Disk Operating System: It is a collection of computer systems capable of communicating
and co-operating via their hardware and software interconnections. It evolves from computer
network in which a number of largely independent hosts are connected by communication
links and protocols.
5. Window Operating System: Microsoft windows was initially developed as a front end
based application. It allows more computer user to use a compatible commands, its hardware
requirements are greater than each other in terms of main memory.
26
HOW OPERATING SYSTEM WORKS
When you turn on the computer, the operating system program is loaded into the main
memory. This program is called the kernel. Once initialized, the system program is prepared to
run the user programs and permits them to use the hardware efficiently. Windows XP is an
excellent example that supports different types of hardware configurations from thousands of
vendors and accommodates thousands of different I/O devices like printers, disk drives, scanners
and cameras.
For example if we want to perform some paintings on the screen, then we must use the
application software as paint and hardware as a mouse for drawing an object. but how the system
knows what to do when mouse moves on the screen and when the mouse draws a line on the
system so that operating system is necessary which interact between or which communicates
with the hardware and the software.
27
CHAPTER EIGHT
INTERUPT
An interrupts mechanism is a facility built into the hardware of processor. An interrupt is a
signal from an external device to a processor that cause the processor to pause from completion of
its current instructions. When an interrupt occurs, the operating system gains control, it then save
the state of the interrupted process.
TYPES OF INTERUPT
1. INPUT/OUTPUT INTERUPT: These are initiated by the input/output hardware. They
signal to the system unit that the status of a device has changed.
2. External interrupt: These caused by the pressing of an interrupt key by the operator.
3. Restart Interrupt: These occur when the operator presses the restart button or when a restart
signal process instruction beeps during a performing task.
5. Program Check Interrupt: These are caused by various types of errors experienced by a
running process such as an attempt by a user to execute a privileged instruction or an attempts
to execute an invalid operation code.
28
PARSE TREE
One intermediate form of an arithmetic statement is the parse tree, it is also called syntax
tree or binary tree. It is used as an aid to understanding the sentence created in a program.
The rules of converting an arithmetic statement into a parse tree is that every operator
construct a binary tree whose left branch is the operand and whose right branch is the tree for the
second operand.
1. A + B
+
A B
2. C = A*B
C *
A B
29
CREATING AND RUNNING PROGRAMS
The following are the four steps in this process
DEFINITION OF TERMS
1. TOKEN: This is the smallest indivisible part of a source program i.e smallest basic unit of a
source program.
2. SENTENCE: A sentence is a finite length string of symbols of the alphabet.
3. LANGUAGE: This is the body of words and methods of combining words that are used and
understand by a considerable community. It is a set of words and the operation of those words.
4. LEXICON: This is the collection of valid words in a particular programming language
5. SYMBOL: These are the letters, digits, special characters which are mainly to generate
language.
30