Chapter One
Chapter One
CHAPTER ONE
PROBLEM SOLVING USING COMPUTERS
Computer software
Software is a term for computer programs. A program is a set of instructions that enables a computer to
operate or instructions that tell the computer how to perform a specific task.
Computer software has two major categories:
System software
Application software
Systems software
Systems software includes the computer's basic operating system and language software. The term also
usually covers any software used to manage the computer and the network. Thus we can say that systems
software includes operating systems, device drivers, programming tools, utilities and more.
Language Software
Are software which are used by programmers to develop application software and translate
programs to machine code.
Language software is a generic name consisting of various programs that serve as editors &
translators to develop programs in a number of programming languages.
Includes: - Translators, general purpose routines and utilities & high level languages
1) Translator: - is a program that converts one or more languages to another language. The
three types of translators are assemblers, Compilers & interpreters.
a. Assemblers: - is a program that translates assembly languages into machine code.
b. Compiler: - is a program that translates a high level language into machine code.
(Pascal, Fortran Cobol)
c. Interpreter: - is a program that translates each instruction of high-level language &
executes the instruction before translating the next instruction.
2) The general-purpose routine and utilities include programs, which are used to handle file
processing, editing and debugging.
3) High-level language software is software, which have their own compilers to detect syntax
errors of the user’s program code.
a. For example Cobol, Fortran, Pascal, C/C++ etc.
Programming Language
A language is a systematic set of rules for communicating ideas. With a natural language, like English, the
communication is between people and the language is used in both spoken and written. A programming
language is a language for communication between a person and computer. The content of communication
is known as a program. Programs are set of instructions, which enable a computer to perform a required
operation.
Several hundred programming languages are in use today, each varying in their specific syntax, but
showing similarities in purpose. Input/output instructions, arithmetic instructions, logic instructions,
control instructions, data movement instructions and specification instructions are such common purpose
instructions. Together with the improvement of hardware and processing speed and memory size increase
Page 1 of 10 DMU
Computer programming Chapter one Computer System
computer languages changed to languages that were easier for humans to understand. So generations of
programming languages are developed to correspond with the generations of computer hardware.
There are five generations of programming language. These generations of programming languages can
also be categorized into two broad categories: -low and high-level languages. Low-level languages are
machine-dependent; that is, they are designed to be run on a particular computer. In contrast, high-level
languages (for example, COBOL and BASIC) are machine-independent and can be run on a variety of
computers.
The first two generations were low-level and the rest high-level of programming languages.
The higher-level languages do not provide us with greater programming capabilities, but they do provide a
more sophisticated program/computer interaction with simple instructions. In short, the higher the level of
the language, the easier it is to understand and use. For example, in a fourth-generation language you need
only instruct the computer system what to do, not necessarily how to do it.
When programming in one of the first three generations of languages, you have to tell the computer what to
do and how to do it. What comprises a new generation is less clear; therefore, languages after the fourth
generation are referred to as very high-level languages.
With each new level, fewer instructions are needed to tell the computer to perform a particular task. A
program written in a second-generation language that computes the total sales for each sales representative,
then lists those over quota, may require 100 or more instructions; the same program in a fourth-generation
language may have fewer than 10 instructions.
The ease with which the later generations can be used is certainly appealing, but the earlier languages also
have their advantages. All generations of languages are in use today.
Software Engineering" has been used to describe "building of software systems which are so large or so complex that
they are built by a team or teams of engineers".
Page 2 of 10 DMU
Computer programming Chapter one Computer System
Implementation
During implementation, we translate (code) each step of the algorithm in the design specifications into a
statement in the particular language selected, and end up with a computer program.
Page 3 of 10 DMU
Computer programming Chapter one Computer System
Maintenance
Changes in hardware, software, documentation, or procedures to correct errors, meet new requirements, or improve
processing efficiency.
1. It is probable that you may come back to this program sometime in the future in order to use it again, or you
may want to use part of it in developing the solution for another similar problem.
2. If you have developed this program for a client's use, he or she will need some information so that in your
absence the program can be used.
3. If you are working for a company and have developed this program as an addition to the company's software
library, some other programmer may be assigned to maintain it or to make additions to it.
4. It is possible that sometime after you have developed the program, you may discover some errors in it and you
may be required to correct them.
The significance of proper program documentation in the software life cycle cannot be overemphasized. Program
documentation consists of
Algorithm development
An algorithm is procedure for solving a problem in terms of
the action to execute (what to do) and
the order in which these actions are executed(done)-how to do
An algorithm needs to be
Precise and unambiguous (no ambiguity in any instruction and in the order of execution)
Simple
General (one inch is equal to 2.54cm is not an algorithm, it has to convert a supplied number of inches)
Correct
Finite (has to have an end)
Handles all expectations
Produce expected output
Efficient: in time, memory and other resources
An algorithm can be expressed in many ways. Some of these methods are narrative, flowchart and pseudo-code:
Page 4 of 10 DMU
Computer programming Chapter one Computer System
Narrative: often used to narrate the algorithm, can be understood by any user who may not have any knowledge of
computer programming. Too wordy, too ambiguous and can be interpreted in different ways.
Example: Accept salary of the employee. Calculate bonus as 10% of salary and add it to salary. Accept service year
of employee. If the service year is greater than 10, give additional 100 birr as bonus. Display the bonus of the
employee.
Flowcharts: a diagram consisting of labeled symbols, together with arrows connecting one symbols to another.
On-page Connector: used to connect two points without drawing a flow line
Example: A certain company plan to give a 10% bonus to each of its employees at the end of every year. If an
employee has been working 10/more years at the company, she/he is to get an additional birr 100. Draw a flowchart
of an algorithm to calculate and print the bonus for a given employee.
Solution:
Analysis: the problem is to compute bonus for employee. To do so, the salary and number of service years of the
employee must be known. Let the salary be denoted by SAL, service be denoted by YEAR and bonus by BONUS.
To compute the bonus, we multiply the salary by 10% and assign the result to BONUS. Thus, BONUS = SAL *
0.10. If the employee has served at least 10 years, birr 100 is added to the computed bonus of the employee and the
result is displayed. Otherwise the originally computed bonus is displayed.
Page 5 of 10 DMU
Computer programming Chapter one Computer System
READ
SAL,
YEAR
Bonus
0.1*SAL
0.1*SAL
No
BONUS
YEAR> =BONUS+100
=10
Yes
WRIT
E
BONU
STOP
Start
Display NAME,
INTEREST
Stop
Page 6 of 10 DMU
Read A, B
Computer programming Chapter one Computer System
Page 7 of 10 DMU
Computer programming Chapter one Computer
System
Start
Count=1
Yes
MARK>80? GRADE-A
No
Yes GRADE-B
MARK>60 ?
No
Yes GRADE-C
MARK>50?
No
Yes GRADE-D
MARK>40 ?
No
GRADE-F
Increment Count
No
Count>10 ?
yes
Display NAME, GRADE Stop
Page 8 of 10 DMU
Computer programming Chapter one Computer
System
Pseudo-code:
It is much similar to real code. We use verbs to write pseudo-code. Capitalize important words that show
actions.
Eg 1) A pseudo-code to calculate interest rate
ACCEPT Name, Principal, Rate
Interest=Principal X Rate
DISPLAY Name, Interest
2) A pseudo-code to calculate bonus
ACCEPT Name, Salary
Bonus=SalaryX0.1
ACCEPT Serviceyear
IF Serviceyear>10 Then
Bonus+100
ENDIF
DISPLAY Bonus
3) A pseudo-code that calculates grade
ACCEPT Mark, Name
IF Mark>80 Then
GradeA
ELSE IF Mark>=70 Then
GradeB
ELSE IF Mark>=60 Then
GradeC
ELSE IF Mark>=50 Then
GradeD
ELSE
GradeF
ENDIF
DISPLAY Grade, Name
Most algorithms incorporate three programming conventions
Sequence
Decision and
Repetition
Sequence
STOCK=STOCK+ QUANTITY
Decision
IF HOURS>40
THEN
PERFORM OVERTIME
ELSE
PERFORM REGULAR
ENDIF
Repetition
Page 9 of 10 DMU
Computer programming Chapter one Computer
System
ENDWHILE
Page 10 of DMU
10