Programming Preliminaries (Chapter 3)
Programming Preliminaries (Chapter 3)
Programming Preliminaries
Chapter 3 Page 2 Nawaraj Paudel
High-level Language
High level languages are simple and easy to understand. These languages assist
programmers by reducing further the number of computer operation details they had to
specify, so that they could concentrate more on the logic needed to solve the problem.
There are three different types of high-level languages:
Procedural and Object-oriented language: These languages are general
purpose programming languages. Procedural programming is a type of
programming where a structured method of creating programs is used. With
procedure-oriented programming, a problem is broken up into parts and each part
is then broken up into further parts. All these parts are known as procedures. They
are separate but work together when needed. A main program centrally controls
them all. Some procedure-oriented languages are COBOL, FORTRAN, and C.
Object-oriented programming is the newest and most powerful paradigms.
Object-oriented programming requires the designer to specify the data as well as
the operations to be applied on those data as a single unit. The pairing of data and
the operations that can be done on it is called an object. A program made using
this language is therefore made up of a set of cooperating objects instead of an
instructions list. Some examples are C++, Java, and Smalltalk.
These languages have many advantages over machine and assembly
languages. These are listed below:
o Program statements resemble English and hence are easier to work with.
o Less time is required to program a problem.
o Programs are easier to understand and modify.
o Programming languages are machine-independent.
However, these languages still have some disadvantages compared to machine
and assembly languages:
o Programs execute more slowly.
o These languages use computer resources less efficiently.
Problem-oriented language: These languages are designed to solve specific
problems or develop specific applications by enabling you to describe what you
want rather than step-by-step procedures. These languages are categorized into
several kinds of application development tools as given below:
o Personal computer applications software like word processors,
spreadsheets, database managers etc.
o Query languages and report generators like SQL (Structured Query
Language, QBE (Query by Example) etc. to search a database using
certain selection commands.
o Decision support systems that help managers to make decisions and
financial planning languages.
o Application generators to develop a particular application without writing
detail logic.
Natural language: Natural languages are used in the areas of artificial
intelligence and expert systems. These languages are used to make computers
more humanlike and allow the computer to become smarter. That is, simulate the
learning process by remembering and improving upon earlier information. Two
popular natural languages are LISP and PROLOG.
Programming Preliminaries
Chapter 3 Page 3 Nawaraj Paudel
Program Design
Before writing computer programs we can use different tools to design it. This design
helps the programmer to write computer programs more easily, correctly, and quickly.
Some most useful program design tools are: algorithm, flowchart, and pseudocode.
Algorithm
An algorithm is a finite sequence of instructions for solving a stated problem. A stated
problem is a well-defined task that has to be performed and must be solvable by an
algorithm. The algorithm must eventually terminate, producing the required result. For
example, the following algorithm can be used to compute interest given the values of p,
n, and r.
1. Enter the values of p, n, and r.
2. Calculate interest i using the formula p × n × r / 100.
3. Display interest i as a result.
Properties of a good algorithm:
o Input: A number of quantities are provided to an algorithm initially before the
algorithm begins. These quantities are inputs which are processed by the
algorithm.
o Definiteness: The processing rules specified in the algorithm must be
unambiguous and lead to a specific action.
o Effectiveness: Each instruction must be sufficiently basic such that it can, in
principle, be carried out in a finite time by a person with paper and pencil.
o Finiteness: The total time to carry out all the steps in the algorithm must be finite.
o Output: An algorithm must have output.
o Correctness: Correct set of output must be produced from the set of inputs. For
the same input, it must always produce the same output.
Programming Preliminaries
Chapter 3 Page 4 Nawaraj Paudel
Flowchart
A flowchart is a common type of chart that represents an algorithm or a computer
program showing the steps as boxes of various kinds, and their order by connecting these
with arrows. Flowcharts are used in analyzing, designing, documenting or managing a
process or program in various fields. A typical flowchart may have the following kinds of
symbols.
Circles, ovals, or rounded rectangles: Usually containing the word "Start" or
"End", or another phrase signaling the start or end of a process.
Arrows: Shows flow control. An arrow coming from one symbol and ending at
another symbol represents that control passes to the symbol the arrow points to.
Rectangle: Represents processing steps.
Parallelogram: Represents input and output.
Diamond: Represents condition or decision. These typically contain a Yes/No
question or True/False test. This symbol is unique in that it has two arrows
coming out of it, usually from the bottom point and right point, one corresponding
to Yes or True, and one corresponding to No or False. The arrows should always
be labeled.
For example, the flowchart to calculate bn can be given as follows:
Start
Input b & n
p=1&i=1
i ≤ n? F Output p
T
p=p×b End
i=i+1
Pseudocode
It is also called program design language (PDL) or structured English. It is a language
and syntax for designing a computer program based on the relative strengths of structured
programming and Natural English. At first glance, PDL looks like a modern
programming language. The difference between PDL and a real programming language
lies in the use of narrative text embedded directly within PDL statements. In pseudocode,
we can use language constructs like IF, SWITCH, FOR, WHILE, and DO-WHILE along
with Natural English. For example,
Programming Preliminaries
Chapter 3 Page 5 Nawaraj Paudel
ASCII
It is the acronym for the American Standard Code for Information Interchange. ASCII is
a code for representing English characters as numbers, with each letter assigned a number
from 0 to 127. For example, the ASCII code for uppercase M is 77. Most computers use
ASCII codes to represent text, which makes it possible to transfer data from one
computer to another.
Text files stored in ASCII format are sometimes called ASCII files. Text editors and
word processors are usually capable of storing data in ASCII format, although ASCII
format is not always the default storage format.
The standard ASCII character set uses just 7 bits for each character, meaning it
can have 128 identifiers, two to the seventh power (2 7). There are several larger character
sets that use 8 bits, which gives them 128 additional characters. The extra characters are
used to represent non-English characters, graphics symbols, and mathematical symbols.
Text Editor
A text editor, such as Notepad, is an application program that can be used to create,
view, edit, save, and print text files. Text files only contain plain text. These programs
provide fewer formatting options than word processors. Text editors can be used to write
computer programs or create other documents. Text editors are often provided with
operating systems or software development packages.
Programming Preliminaries
Chapter 3 Page 6 Nawaraj Paudel
Programming Preliminaries
Chapter 3 Page 7 Nawaraj Paudel
The next phase is called implementation. In this phase, the information system is coded,
tested, installed, and supported in the organization. During coding, programmers write
the programs that make up the information system. During testing, programmers and
analysts test individual programs and the entire system in order to find and correct errors.
During installation, the new system becomes a part of the daily activities of the
organization. Implementation activities also include initial user support such as the
finalization of documentation, training programs, and ongoing user assistance.
The final phase of SDLC is called maintenance. In this phase, information
system is systematically repaired and improved. When a system is operating in an
organization, users sometimes find problems with how it works and often think of better
ways to perform its functions. Also the organization’s needs with respect to the system
change over time. In maintenance, you make the changes that users ask for and modify
the system to reflect changing business conditions.
Programming Preliminaries