0% found this document useful (0 votes)
2 views52 pages

Programming Principle 01

The document outlines the fundamental principles of computer systems, detailing the components of hardware and software, including input devices, CPU, storage, and types of software. It explains the evolution of programming languages from machine languages to high-level languages and introduces algorithms as a structured approach to problem-solving in programming. Additionally, it discusses the design of algorithms using pseudocode and flowcharts, highlighting their advantages and disadvantages.

Uploaded by

prince
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views52 pages

Programming Principle 01

The document outlines the fundamental principles of computer systems, detailing the components of hardware and software, including input devices, CPU, storage, and types of software. It explains the evolution of programming languages from machine languages to high-level languages and introduces algorithms as a structured approach to problem-solving in programming. Additionally, it discusses the design of algorithms using pseudocode and flowcharts, highlighting their advantages and disadvantages.

Uploaded by

prince
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

ITT 04107

PROGRAMMING PRINCIPLE

Prince John John

5/11/2026 1
Computer Systems:
A computer is a system made of two major components: hardware and software. The
computer hardware is the physical equipment. The software is the collection of
programs (instructions) that allow the hardware to do its job.

Computer System

Hardware Software

5/11/2026 2
Computer Hardware

The hardware component of the computer system consists of five parts: input devices,

central processing unit (CPU) ,primary storage, output devices, and auxiliary storage

devices.

5/11/2026 3
The input device is usually a keyboard where programs and data are

entered into the computers. Examples of other input devices include a

mouse, a pen or stylus, a touch screen, or an audio input unit.

5/11/2026 4
The central processing unit (CPU) is responsible for executing

instructions such as arithmetic calculations, comparisons among

data, and movement of data inside the system. Today’s

computers may have one ,two, or more CPUs

5/11/2026 5
Primary storage ,also known as main memory, is a place where the

programs and data are stored temporarily during processing. The data in

primary storage are erased when we turn off a personal computer or when

we log off from a time-sharing system.

5/11/2026 6
The output device is usually a monitor or a printer to show output. If

the output is shown on the monitor, we say we have a soft copy. If it

is printed on the printer, we say we have a hard copy.

5/11/2026 7
Auxiliary storage, also known as secondary storage, is used for both
input and output. It is the place where the programs and data are
stored permanently. When we turn off the computer, or programs
and data remain in the secondary storage, ready for the next time
we need them.

5/11/2026 8
Computer Software

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.

5/11/2026 9
System Software:

System software consists of programs that manage the hardware


resources of a computer and perform required information processing
tasks. These programs are divided into three classes: the operating
system, system support, and system development.

5/11/2026 10
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.

5/11/2026 11
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.

5/11/2026 12
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 and computer –assisted software engineering(CASE)
systems.

5/11/2026 13
Application software

Application software is broken in to two classes :general-purpose


software and application – specific software.

General purpose software is purchased from a software developer


and can be used for more than one application.

Examples of general purpose software include word processors


,database management systems ,and computer aided design
systems. They are labeled general purpose because they can solve
a variety of user computing problems.
5/11/2026 14
Application –specific software can be used only for its intended purpose.

A general ledger system used by accountants and a material requirements


planning system used by a manufacturing organization are examples of
application-specific software. They can be used only for the task for which
they were designed they cannot be used for other generalized tasks.

5/11/2026 15
The relation ship between system and application software is
shown in the figure below , each circle represents an interface
point .

The inner core is hard ware. The user is represented by the out
layer. To work with the system, the typical user uses some form
of application software.

5/11/2026 16
The application software in turn interacts with the operating system
,which is apart of the system software layer. The system software
provides the direct interaction with the hard ware. The opening at the
bottom of the figure is the path followed by the user who interacts
directly with the operating system when necessary.

5/11/2026 17
5/11/2026 18
Computer Languages:

To write a program for a computer, we must use a computer


language. Over the years computer languages have evolved
from machine languages to natural languages.

1940 Machine level Languages


1950’s Symbolic Languages
1960’s High-Level Languages

5/11/2026 19
Machine Languages
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.
Instructions in machine language must be in streams of 0’s and 1’s because
the internal circuits of a computer are made of switches transistors and other
electronic devices that can be in one of two states: off or on. The off state is
represented by 0 , the on state is represented by 1.
The only language understood by computer hardware is machine language.

5/11/2026 20
Symbolic Languages:

In 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.

5/11/2026 21
The early programming languages simply mirror to the machine languages
using symbols of mnemonics to represent the various machine language
instructions because they used symbols, these languages were known as
symbolic languages.
Computer does not understand symbolic language it must be translated to
the machine language. A special program called assembler translates
symbolic code into machine language. Because symbolic languages had to
be assembled into machine language they soon became known as
assembly languages.
Symbolic language uses symbols or mnemonics to represent the various
,machine language instructions.

5/11/2026 22
High Level Languages:
Symbolic languages greatly improved programming effificiency; 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 has to be individually coded. The desire to improve programmer
efficiency and to change the focus from the computer to the problem being
solved led to the development of high-level language.

5/11/2026 23
High level languages are portable to many different computers, allowing the
programmer to concentrate on the application problem at hand rather than
the intricacies of the computer. High-level languages are designed to relieve
the programmer from the details of the assembly language. High level
languages share one thing with symbolic languages, They must be converted
into machine language. The process of converting them is known as
compilation.

5/11/2026 24
The first widely used high-level languages, FORTRAN (FORmula
TRANslation)was created by John Backus and an IBM team in 1957;it is
still widely used today in scientific and engineering applications. After
FORTRAN was COBOL(Common Business-Oriented Language). Admiral
Hopper was played a key role in the development of the COBOL
Business language.
C is a high-level language used for system software and new application
code.

5/11/2026 25
ALGORITHM:
Algorithms was developed by an Arab mathematician. It is chalked out step-
by-step approach to solve a given problem. It is represented in an English like
language and has some mathematical symbols like ->, >, <, = etc.. Algorithm is a
penned strategy(to write) to find a solution.

5/11/2026 26
History of Algorithm
• The word algorithm comes from the name of a Persian author, Abu Ja’far
Mohammed ibn Musa al Khowarizmi (c. 825 A.D.), who wrote a textbook on
mathematics.
• He is credited with providing the step-by-step rules for adding, subtracting,
multiplying, and dividing ordinary decimal numbers.
• When written in Latin, the name became Algorismus, from which algorithm is
but a small step
• This word has taken on a special significance in computer science, where
“algorithm” has come to refer to a method that can be used by a computer for
the solution of a problem

5/11/2026 27
To solve a given problem or to write a program you
approach towards solution of the problem in a systematic,
disciplined, step-by-step way is called Algorithmic
approach

5/11/2026 28
Before developing a program, is it important that a programmer specifies the
order in which the set of instructions contained in the program are to be
executed. This process of defining the step-by-step procedure in which the
instructions are to be executed is known as algorithm design. In this unit, we
begin by defining algorithm concepts followed by discussion on tools used to
design algorithms. Later, we demonstrate how to express algorithm’s logic and
concepts using pseudocode and flowcharts.

5/11/2026 29
To ensure that an algorithm produces desired solution, a programmer is
tasked with the following roles:
1. Identify a problem that may be solved using a computer program.
2. Outline the social and technological factors that need to be
considered before converting the problem into a computer program.
3. Provide possible solutions to a problem. This may be by means of
using off-the shelf software or custom-made software.

5/11/2026 30
Characteristics of Algorithm
A good algorithm is crucial to development of good computer programs.
Some of the characteristics of good algorithms include:
• Correctness: The goal during program design is to produce logical designs.
The design of a system is correct if the system satisfies user’s requirements.
It is the responsibility of a programmer to find the best possible design
within the limitations imposed by the requirements and environment in
which the program will be used.

5/11/2026 31
• Verifiability: Verifiability is concerned with how easily the correctness

of the design can be checked. Design should be correct and it should be

verified for correctness.

• Completeness: Completeness requires that designs of different system

components be verified. This requires dry-running of system’s data

structures, modules, user interfaces, and module integration.

5/11/2026 32
• Traceability: In order for a program to meet user’ needs and

expectations, it is important that the entire design be traceable from

user requirements.

• Efficiency: Good design results in an efficient program that

consumes less processor time and memory space

5/11/2026 33
• Simplicity: Though a program may be complex, its simplicity is one of

the most important factors that influence its user-friendliness and ease of

maintenance.

• Documentation: It is good practice to provide documentation

containing details of a program algorithms

5/11/2026 34
Role and Structure of algorithms

The role of algorithms is to support programmers in designing and implementing computer programs that solve

a problem of importance. For example, consider a problem of finding the shortest route to travel between Dar

es salaam to Kilimanjaro. To solve such a problem, algorithm design follows a structured approach outlined

below:

1. The programmer first analyses the problem to come up with problem specification as shown in Fig. 7.1. A

problem specification defines input, processing and output required to solve the problem

2. Map the problem specification into an algorithm that defines the logic or procedure for solving the problem.

3. Once an algorithm has been designed and tested against problem specifications, implement it as a program

using suitable programming languages.

4. Finally the program is installed on computers or portable devices to solve the problem.

5/11/2026 35
5/11/2026 36
Design of Algorithms
Algorithms can be expressed in many ways such as using natural
languages, pseudocode, and flowcharts used for complex or technical
algorithms. To avoid ambiguities common in natural language
statements, most programmers prefer using structured design tools like
pseudocode and flowcharts discussed in details later.

5/11/2026 37
Natural language
The term natural language refers to the ordinary language likes English or
Swahili used by human beings to communicate with each other in speech or
writing. Because an algorithm is a procedure for solving a problem, the
natural languages can be used to express the steps to be followed to solve a
specific problem.

5/11/2026 38
For example, the following is natural language algorithm for how to make a hot sauce:
1. Before you prepare a hot sauce, make sure you have garlic that is peeled and chopped, fresh
lime juice, distilled white, vinegar, olive oil, molasses, turmeric and salt.
2. Now, combine the pepper, garlic, lime juice, vinegar, mustard, oil, molasses, turmeric, and
salt in a blender and puree until smooth. Correct the seasoning, adding more salt or molasses to
taste.
3. Transfer the sauce to a clean bottle. You can serve it right away, but the flavor improves if you
let it age for a few days.

5/11/2026 39
The above ‘algorithm’ is a recipe, that is, a step-by-step instructions that takes
raw ingredients and produces a tasty product – hot sauce. However, one of
the limitations of such an algorithm is that it tends to be verbose or
ambiguous. Furthermore, there are different languages in the world which
makes it difficult for an algorithm written in a particular language to be
universal. To avoid ambiguities inherent in natural languages, there are
language independent tools such as pseudocode and flowcharts discussed
later in this section.

5/11/2026 40
Activity 1 Natural Language Algorithm
1. Consider a daily routine of waking up and going to class. Outline an algorithm named
“wakeup-to-class” starting with getting out of bed to attending the first lesson of the day. If
the routine is to be computerized, specify the order in which
statements are to be executed.

5/11/2026 41
Flowcharts
A (or flowchart) is a diagram that shows an overview of a Flow diagrams
normally use standard symbols to represent the different types of these
symbols are used to construct the flowchart and show the step-by-step
solution to the problem. Flow diagrams are sometimes known as
flowcharts.

5/11/2026 42
Common flow diagram symbols

5/11/2026 43
Guidelines for Developing Flowcharts

These are some points to keep in mind while developing a flowchart −

1. Flowchart can have only one start and one stop symbol

2. General flow of processes is top to bottom or left to right

3. Arrows should not cross each other

5/11/2026 44
Here is a flowchart to calculate the average of two numbers.

5/11/2026 45
Flow diagrams can be used to plan out programs. This simple flow diagram maps out
an for a program that prints the numbers 1 to 10:

5/11/2026 46
Advantages and disadvantages of using flow diagrams

Designing an algorithm using flow diagrams has benefits:

•It is easy to see how a program flows.

•Flow diagrams follow an international; it’s easy for any flow diagram user to

pick up a diagram and understand it.

5/11/2026 47
Flow diagrams also have their disadvantages:

i. with a large program, the diagrams can become huge in size and unwieldy to

follow

ii. any changes to the design may mean a lot of the diagram has to be redrawn

5/11/2026 48
Pseudocode

Most are developed using . These languages have specific that must be used so

that the program will run properly.

is not an actual programming language. Instead, it is a simple way of describing a

set of instructions in a manner that resembles a programming language. It has its

own syntax, some of which is very similar to many actual programming languages.

5/11/2026 49
Producing algorithms with pseudocode

Any designed using pseudocode will not run unless they are converted

into an actual programming language.

5/11/2026 50
Advantages and disadvantages of pseudocode
Designing an algorithm in pseudocode has benefits:
•because pseudocode is similar to a programming language, it can be quickly
and easily converted into an actual programming language
•it is fairly easy to understand, even for non-programmers
•it does not matter if there are errors in the syntax - it is usually still obvious what
is intended
•changes to the design can be incorporated quite easily

5/11/2026 51
Pseudocode also has its disadvantages:

•It can be hard to see how a program flows, for example, where does

following one path as opposed to another take the program?

•It can be time consuming to produce.

5/11/2026 52

You might also like