Computerprogramming
Computerprogramming
computer
There are
and Problem-oriented.
You know that a computer can understand only special signals, which are
represented by 1s and 0s. These two digits are called binary digits. Computer
understands program written in binary digits. The language, which uses binary
digits, is called the machine level language. Computer works in bits and bytes. It
understands the language of the binary digits, 0 and 1. You may write a program
in whichever language you want, but it is finally converted into the language of 0s
and 1s before it gets executed. Writing a program in machine language is
definitely very difficult. It is not possible to memorize a long string of 0s and 1s
for every instruction that you want to derive executed. It is proper that before the
higher levels of programming languages were designed, machine languages were
old-fashioned for writing programming codes, but they are no longer traditional
for designing computer programs.
A machine language is a collection of very detailed cryptic instructions that
control computers internal circuitry. It is language that a computer actually
understands. It is viewed as sequences of 1`s and 0`s that a program written in
any language is finally translated to. In machine language program, the
computation is based on binary numbers. All the instructions including operations,
registers, data and memory locations are given in there binary equivalent.
The machine directly understands this language by virtue of its circuitry design so
these programs are directly executable on the computer without any translations.
This makes the program execution very fast. Machine languages are also known
as first generation languages.
A machine language consists of the numeric codes for the operations
that a particular computer can execute directly. The codes are strings of 0s and
1s, or binary digits (bits), which are frequently converted both from and to
Suneel Dogra
SD College Hoshiarpur
hexadecimal (base 16) for human viewing and modification. Machine language
instructions typically use some bits to represent operations, such as addition, and
some to represent operands, or perhaps the location of the next instruction.
Machine language is difficult to read and write, since it does not resemble
conventional mathematical notation or human language, and its codes vary from
computer to computer.
Machine language is the only language that a computer understands.
Each statement in a machine language program is a sequence of bits. Each bit
may be set to 0 or 1. Series of bits represent instructions that a computer can
understand. For example, the number 455 is represented by the bit sequence
111000111. Machine language is a low-level programming language. It is easily
understood by computers but difficult to read by people. This is why people use
higher level programming languages. Programs written in high-level languages
are compiled and/or interpreted into machine language so computers can execute
them.
ASSEMBLY LANGUAGE:
The first step in the evolution of programming languages was the development of
what is known as an assembly language. In an assembly language, mnemonics
are used to represent operations to be
Suneel Dogra
SD College Hoshiarpur
Suneel Dogra
SD College Hoshiarpur
assembly
language
statements
like
MOV
and
ADD
are
more
Suneel Dogra
SD College Hoshiarpur
language, high degree of portability is the benefit provided by only few high-level
languages and absolute portability is still a big quest of the day.
Although, nearly whole of the programming world is dominated by the high level programming languages due to their higher program efficiency and
productivity, the assembly language still maintains its place in low level
programming and hardware interaction, especially for high performance systems.
PROCEDURAL LANGUAGE:
Procedural language is a computer programming language that specifies a series
of well-structured steps and procedures within its programming context to
compose a program. It contains a systematic order of statements, functions and
commands to complete a computational task or program. Procedural language is
also known as imperative language.
Procedural language, as the name implies, relies on predefined and wellorganized procedures, functions or sub-routines in a programs architecture by
specifying all the steps that the computer must take to reach a desired state or
output.
Procedural language segregates a program within variables, functions,
statements and conditional operators. Procedures or functions are implemented
on the data and variables to perform a task. These procedures can be
called/invoked anywhere between the program hierarchy, and by other
procedures as well. A program written in procedural language contains one or
more procedures.
Procedural language is one of the most common programming languages in use
with notable languages such as C/C++, Java, Cold Fusion and PASCAL.
Suneel Dogra
SD College Hoshiarpur
Suneel Dogra
SD College Hoshiarpur
10
For example, in a program that needs to accept, display, and print data, you
can divide the program into subprograms. You can create three subprograms
that accept data, display data, and print data, respectively. Each subprogram
performs a defined function while the combined action of subprograms
makes a complete program.
In procedural programming, you can use a subprogram at multiple locations
within a program to perform a specific task.
This enables you to reuse the program code as and when required in a
program, without rewriting the entire code, as shown in the figure:
The figure displays a program that consists of three procedures. Accept Data,
Display Data, and Print Data. Data is accepted in the Accept Data procedure,
displayed in the Display Data procedure, and printed in the Print Data
procedure.
Procedural programming is used for developing simple applications. The
languages that use the procedural programming methodology include Pascal
and C languages.
Suneel Dogra
SD College Hoshiarpur
11
Code is more flexible as you can change a specific procedure that gets
implemented across the program.
Suneel Dogra
SD College Hoshiarpur
12
NON-PROCEDURAL LANGUAGE:
Programming
languages
that
are
based
on
functions
or
logic
are
programming
languages
allow
users
and
professional
programmers to specify the results they want without specifying how to solve
the problem. Examples are FORTRAN, C++, COBOL, ALGOL etc. A computer
language that does not require writing traditional programming logic. Also
known as a "declarative language," users concentrate on defining the input
and output rather than the program steps required in a procedural
programming language such as C++ or Java. Functional programming is
about writing and composing functions. The central idea lies in symbolic
manipulation as computation -- the use of recursive functions defined over
lists provides a computational framework with the full power of expressing
deterministic computations. You will be presented with a brief overview of
functional programming in LISP, and you will use it to solve a number of
problems. We will introduce lambda calculus as a foundation for functional
programming, and an abstract machine called SECD as a model of executing
compiled lisp programs.
Logic programming draws the idea of programming as specifying solutions in
a logic and logic deduction as computation. You will learn how to turn a
Suneel Dogra
SD College Hoshiarpur
13
subset of logic into a programming language. For the practical aspect, you
will write small yet interesting programs in Prolog (Programming in Logic).
We will also introduce constraint programming, perhaps one of the most
exciting developments in programming languages in the last decade.
PROBLEM-ORIENTED LANGUAGE:
These are high level language designed for developing a convenient
expression of the given class of problem.
STRUCTURED PROGRAMMING
Structured programming (sometimes known as modular programming) is a
subset of procedural programming that enforces a logical structure on the
program being written to make it more efficient and easier to understand
and modify. Certain languages such as Ada, Pascal, and dBASE are designed
with features that encourage or enforce a logical program structure.
Structured programming frequently employs a top-down design model, in
which developers map out the overall program structure into separate
subsections. A defined function or set of similar functions is coded in a
separate module or sub module, which means that code can be loaded into
memory more efficiently and that modules can be reused in other programs.
After a module has been tested individually, it is then integrated with other
modules into the overall program structure.
Program flow follows a simple hierarchical model that employs looping
constructs such as "for," "repeat," and "while." Use of the "Go To" statement
is discouraged.
Suneel Dogra
SD College Hoshiarpur
14
languages
include
features
that
encourage
structured
15
Suneel Dogra
SD College Hoshiarpur
16
1. Define exactly what data the program will get and what it has to do with
them.
2. If the task is simple enough, write the program code.
3. Otherwise, split the task into smaller parts and define exactly the duty of
each part and interface to the rest of the program.
4. Repeat the steps 14 separately for each subtask.
MODULAR PROGRAMMING
Modular
programming
(also
called
"top-down
design"
and
"stepwise
17
functions are grouped in the same unit of programming code and separate
functions are developed as separate units of code so that the code can be
reused
by
Object-oriented
other
programming
(OOP)
is
applications.
compatible
with
the
modular
require
knowledge
of
all
modules
in
the
system.
Each and every modular application has a version number associated with it.
This provides developers flexibility in module maintenance. If any changes
have to be applied to a module, only the affected subroutines have to be
changed.
This
makes
the
program
easier
to
read
and
understand.
Modular programming has a main module and many auxiliary modules. The
main module is compiled as an executable (EXE), which calls the auxiliary
module functions. Auxiliary modules exist as separate executable files, which
load when the main EXE runs. Each module has a unique name assigned in
the PROGRAM statement. Function names across modules should be unique
for easy access if functions used by the main module must be exported.
Languages that support the module concept are IBM Assembler, COBOL,
RPG, FORTRAN, Morpho, Zonnon and Erlang, among others.
Suneel Dogra
SD College Hoshiarpur
18
Suneel Dogra
SD College Hoshiarpur
19
Suneel Dogra
SD College Hoshiarpur
20