Chapter One
INTRODUCTION TO PROGRAMMING
A COMPUTER IS AN ELECTRONIC DEVICE THAT ACCEPTS DATA, PERFORMS
COMPUTATIONS, AND MAKES LOGICAL DECISIONS ACCORDING TO INSTRUCTIONS THAT
HAVE BEEN GIVEN TO IT
A PROGRAM IS A SET OF INSTRUCTIONS THAT TELL THE COMPUTER TO DO VARIOUS
THINGS; SOMETIMES THE INSTRUCTION IT HAS TO PERFORM DEPENDS ON WHAT
HAPPENED WHEN IT PERFORMED A PREVIOUS INSTRUCTION.
PROGRAMMING IS THE PROCESS OF CREATING A SET OF INSTRUCTIONS THAT TELL A
COMPUTER HOW TO PERFORM A TASK. PROGRAMMING CAN BE DONE USING A VARIETY
OF COMPUTER "LANGUAGES," SUCH AS SQL, JAVA, PYTHON, AND C++.
COMPUTER PROGRAMMING (OFTEN SHORTENED TO PROGRAMMING OR CODING) IS
THE PROCESS OF WRITING, TESTING, DEBUGGING/TROUBLESHOOTING, AND
MAINTAINING THE SOURCE CODE OF COMPUTER PROGRAMS.
Cont..
A computer program usually consists of two elements:
Data – characteristics
Code – action
Computer programs (also known as source code) are often written by professionals
known as Computer Programmers (simply programmers).
Source code 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.
The syntax of a language describes the possible combinations of symbols that form a
syntactically correct program.
syntax:grammatical rules for forming instructions
semantics: meaning/interpretation of instructions
The meaning given to a combination of symbols is handled by semantics.
Many Aspects of Programming
Programming is problem solving
always trying to make computer do something useful — i.e., finding an optimal travel route
Programming is controlling
computer does exactly what you tell it to
Programming is teaching
computer can only “learn” to do new things if you tell it how
Programming is creative
must find a good solution out of many possibilities
Programming is modeling
describe salient (relevant) properties and behaviors of a system of components (objects)
Programming is abstraction
identify important features without getting lost in detail
What skills do we need to be a programmer?
For someone to be a programmer, in addition to basic skills in computer, needs to have
the following major skills:
Programming Language Skill:.
Problem Solving Skill:
Algorithm Development:
Generation of programming language?
Computer organizations?
Operating system evolutions?
Types of programming languages
an artificial language that can be used to control the behavior of a computer
Every programming language has syntax and semantics.
programming languages can be categorized into two broad categories:
1. low level programming languages
a. Machine languages:
Difficult to write applications with.
Dependent on machine languages of the specific computer being used.
Machine languages allow the programmer to interact directly with the hardware, and it
can be executed by the computer without the need for a translator.
Is more powerful in utilizing resources of the computer.
Gives power to the programmer.
They execute very quickly and use memory very efficiently.
Cont..
b. Assembly languages:
Uses symbolic names for operations and storage locations.
A system program called an assembler translates a program written in assembly
language to machine language.
Programs written in assembly language are not portable. i.e., different computer
architectures have their own machine and assembly languages.
They are highly used in system software development.
2. High level Programming languages
Uses English like instructions and mathematicians were able to define variables
with statements such as Z = A + B
Such languages are much easier to use than assembly language. Programs written
in high level languages need to be translated into machine language in order to be
executed.
The use of common words (reserved words) within instructions makes them
easier to learn.
All third generation programming languages are procedural languages.
In procedural languages, the programmer is expected to specify what is required
and how to perform it.
Compilers and Interpreters
Any program written in a language other than machine language needs to be
translated to machine language. The set of instructions that do this task are known as
translators.
There are different kinds of translator software, among which compilers and
interpreters are of interest for most programmers.
Compilers: a compiler is a computer program that translates a series of statements
written in source code (a collection of statements in a specific programming language)
into a resulting object code (translated instructions of the statements in a programming
language).
Interpreters: is a computer program that translates a single high level statement and
executes it and then goes to the next high level language line.
Programming paradigm…
A programming paradigm is a fundamental style/way of
programming
1. Unstructured Programming
consisting only of one large (usually main) program , “main
program”' stands for a sequence of commands or statements
data is global throughout the whole program
2. Procedural programming .
Procedural programming is a programming paradigm based upon the concept of
procedure call.
Procedures (routines, subroutines, methods, functions) simply
contain a series of computational steps to be carried out to solve a
problem
Structured Programming
is a subset of procedural programming (also
known as modular programming)
procedures of a common functionality are grouped
together into separate modules
Each module can have its own data
allows each module to manage an internal state which
is modified by calls to procedures of this module
top-down design model
map out the overall program structure into separate
subsections
Example
PASCAL, C
Object Oriented Programming -
OOP
Is a method of implementation in which programs are organized as cooperative
collections of objects
Data and operations are grouped together
Each object is capable of receiving messages, processing data, and
sending messages to other objects
Modeling of the domain as objects so that the implementation naturally reflects the
problem at hand.
Software Development Life Cycle (SDLC)
is a process that produces software with the highest quality and lowest
cost in the shortest time.
SDLC includes a detailed plan for how to develop, alter, maintain, and
replace a software system.
is a conceptual model used in project management that describes the
stages involved in a computer system development project from an
initial feasibility study through maintenance of the completed
application.
Feasibility study
The first step is to identify a need for the new system.
This will include determining whether a business problem or opportunity exists, conducting a
feasibility study to determine if the proposed solution is cost effective, and developing a
project plan.
The process of developing a large information system can be very costly, and the
investigation stage may require a preliminary study called a feasibility study, which includes
e.g. the following components:
a. Organizational Feasibility
How well the proposed system supports the strategic objectives of the organization.
b. Economic Feasibility
Cost savings
Increased revenue
Decreased investment
Increased profits
Cont..
C. Technical Feasibility
Hardware, software, and network capability, reliability, and availability
d. Operational Feasibility
End user acceptance
Management support
Customer, supplier, and government requirements
Requirements analysis
Requirements analysis is the process of analyzing the information
needs of the end users, the organizational environment, and any
system presently being used, developing the functional requirements
of a system that can meet the needs of the users.
Designing solution
After the requirements have been determined, the
necessary specifications for the hardware, software,
people, and data resources, and the information products
that will satisfy the functional requirements of the
proposed system can be determined.
Testing designed solution
A smaller test system is sometimes a good idea in order to get a “proof-of-concept”
validation prior to committing funds for large scale fielding of a system without
knowing if it really works as intended by the user.
Implementation
Systems implementation is the construction of the new system and its delivery into
production or day-to-day operation.
Testing
Unit testing: Normally programs are written as a series of individual modules
Integration and System testing: Brings all the pieces together into a special testing
environment,
Maintenance/Documentation
What happens during the rest of the software's life: changes, correction, additions, and
moves to a different computing platform and more.
Algorithm development and representation
Before a program is written, the programmer must clearly understand what data are to be
used, the desired result, and the procedure to be used to produce the result.
The procedure, or solution, selected is referred to as an algorithm.
An algorithm is defined as a step-by-step sequence of instructions that must terminate and
describe how the data is to be processed to produce the desired outputs. Simply, algorithm is
a sequence of instructions.
The algorithm should be:
Precise and unambiguous, Simple , Correct, Efficient
There are three commonly used tools to help to document program logic (the algorithm).
These are structure chart, flowcharts and Pseudocode.
Structure Chart
in software engineering and organizational theory is a chart which shows the
breakdown of a system to its lowest manageable levels.
They are used in structured programming to arrange program modules into a
tree.
Each module is represented by a box, which contains the module's name.
Pseudocode
is a simple way of writing programming code in English.
Pseudocode is not actual programming language.
It uses short phrases to write code for programs before you actually create it in a specific
language.
Example:- Write a program that obtains two integer numbers from the user. It will print out the
sum of those numbers.
Pseudocode:
Prompt the user to enter the first integer
Prompt the user to enter a second integer
Compute the sum of the two user inputs
Display an output prompt that explains the answer as the sum
Display the result
Flowchart
The flowchart shows the steps as boxes of various kinds, and their order by
connecting the boxes with arrows.
Flowcharts are used in analyzing, designing, documenting or managing a
process or program in various fields.
Flowchart uses different symbols (geometrical shapes) to represent different
processes.
The following table shows some of the common symbols.
Flowchart symbols
Action /process Symbol
Instructions changing a state
Input/output symbol
Decision Symbol
Instructions testing a state
Flowline
Instructions transferring to next step
Start/End Symbol
Cont..
Example 1: - Draw flow chart of an algorithm to add two numbers and display
their result.
Algorithm description The flow chart is
Read the rules of the two numbers (A and B)
Add A and B
Assign the sum of A and B to C
Display the result ( c)
Cont..
Example 2: Write an algorithm description and draw a flow chart to check a number
is negative or not.
Algorithm description.
1 Read a number x
2 If x is less than zero write a message negative
else write a message not negative
Thank you!!