Chapter 1
Chapter 1
Introduction to programming
Introduction to Computer Programming
Computer is an Electronic data processing device which is capable of
performing Arithmetic and Logical operations.
Computer is an Electronic Machine that Receives Data from a user
through an input devices
It stores and send the processed data, to an output device
Computers are important and widely used in our society.
because they are cost-effective to solve problems in business,
government, industry, education, etc.
In order to solve a given problem, computers must be given the correct
instruction about how they can solve it.
Computer programs, software programs, or just programs are the
instructions that tells the computer what to do.
Computer programming (programming or coding) is the process of
writing, testing, debugging/troubleshooting, and maintaining the
source code of computer programs.
Cont.…
• It is written by professionals known as Computer Programmers
(simply programmers).
– it is written in one of programming languages.
• A programming language is an artificial language that can be used to
control the behavior of a machine, particularly a computer.
• Programming languages, like natural language (Amharic, English), are
defined by syntactic and semantic rules which describe their structure
and meaning respectively.
• Many programming languages have their own written syntax and
semantics rules
• The main purpose of programming languages is to provide instructions
to a computer.
• Programming languages can be divided into two major categories:
low-level and high-level languages.
Low-level languages
• Low-level languages are machine-dependent; they are designed to be run
on a particular computer.
• Computers only understand one language i.e. binary language(1s and 0s).
• Binary language is also known as machine language, one of low-level
languages.
• The computer easily understood these programs, but its difficult for
human beings to remember all the instructions in the form of 0s and 1s.
• Therefore, computers remained secret to a common person until other
languages such as assembly language was developed.
Assembly language is symbolic instructions and executable machine codes.
was created to use letters to each machine language instructions to
make it easier to remember or write.
For example: ADD A, B – adds two numbers in memory location A and
B.
a symbolic representation of machine code
• Computers still cannot understand it. The assembly language must be
translated to machine code by a separate program called assembler.
High-level languages
• programming in assembly language is very slow and bulky. In addition it is
hardware specific.
• The lack of portability between different computers led to the development
of high-level languages
– because they permitted a programmer to ignore many low-level details
of the computer's hardware.
• It’s easier for programmers to "think “" in the programming language.
• It also require translation to machine language before execution.
– Compilers translate the entire source code program before execution.
– Interpreters translate source code programs one line at a time.
Example FORTRAN (FORmula TRANslator), BASIC (Bingers All Purpose
Symbolic Instruction Code), PASCAL, C, C++, Java etc.
• Every language has its strengths and weaknesses. For example, FORTRAN
is a particularly good language for processing numerical data, but it does
not lend itself very well to organizing large programs. Pascal is very good
for writing well-structured and readable programs, but it is not as flexible as
the C programming language. C++ embodies powerful object-oriented
features
Programming Paradigm.
• programming languages are characterized (categorized) is by
programming paradigm. A programming paradigm provides the
programmer's view of code execution.
Procedural Programming Languages
• Procedural programming specifies a list of operations that the program
must complete to reach the desired state.
• Each program has a starting state, a list of operations to complete, and
an ending point.
• Procedures are small sections of code that perform a particular function.
• It allows a section of code to be re-used in the program without making
multiple copies.
• It also makes it easier for programmers to understand and maintain
program structure.
• Two of the most popular procedural programming languages are
FORTRAN and BASIC.
Cont.…
Structured Programming Languages
• It is a special type of procedural programming. It provides additional tools
to manage the problems that larger programs were creating.
• Structured programming requires that programmers break program
structure into small pieces of code that are easily understood.
• The most popular structured programming languages include C, Ada, and
Pascal.
Object-Oriented Programming Languages
• it is one the newest and most powerful paradigms.
• In object- oriented programs, the designer specifies both the data
structures and the types of operations that can be applied to those data
structures.
• This pairing of a piece of data with the operations performed on an object.
• A program becomes a collection of cooperating objects, rather than a list
of instructions.
• Objects can store state information and interact with other objects, but
generally each object has a distinct, limited role.
Problem solving techniques
• There are system analysis and design tools (flowchart and structure chart)
to define the problem in terms of steps to its solution.
Cont….
• Before a program is written, the programmer must clearly understand
what data are to be used, the desired result, and the procedure to be