Chapter 1
Chapter 1
disadvantages
◦ Complex
◦ if the same statement sequence is needed at different
locations within the program, the sequence must be copied
based upon the concept of procedure call
A procedure call is used to invoke the procedure
Procedures (routines, subroutines, methods, functions) simply
contain a series of computational steps to be carried out to
solve a problem
• We have a single program, which is divided into small pieces
called procedures
•Advantage
•to re-use the same code at different places in the program
without copying it
•easier way to keep track of program flow
•Example
•FORTRAN, ADA
is a subset of procedural programming (also
)
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
Advantage
◦ Reuse
◦ Easier to understand and modify
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.
Computer solves varieties of problems that can be expressed in
a finite number of steps
In computer programming two facts :
Ø Defining the problem and logical procedures to follow in
solving it.
ØIntroducing the means by which programmers
communicate those procedures to the computer system so
that it can be executed.
There are system analysis and design tools, particularly
flowchart and structure chart, that can be used to define the
problem in terms of the steps to its solution.
The programmer uses programming language to
communicate the logic of the solution to the computer.
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
programs could be written in terms of 3 structures:
◦ Sequence – which instruction should be done next?
◦ Selection – select between options
◦ Repetition – repeat an action while a given condition stays
true
An algorithm can be represented as
◦ Flowchart
◦ Pseudo code
◦ Structured chart
is an artificial and informal language that helps programmers
develop algorithms
a shorthand notation for programming which uses a combination
of informal programming structures and verbal descriptions of
code.
In general, pseudocode is used to outline a program before
translating it into proper syntax.
Example-1:
◦ Write a program that prints “passed” when the student
grade is greater than 60 and “failed” otherwise.
Solution:-
If student's grade is greater than or equal to 60
◦ Print "passed"
else
◦ Print "failed“
Example-2:
◦Pseudo-code the task of computing the final price of an item
after figuring in sales tax. Note the three types of instructions:
input (get), process/calculate (=) and output (display)
1. get price of item
2. get sales tax rate
3. sales tax = price of item times sales tax rate
4. final prince = price of item plus sales tax
5. display final price
6. stop
Example-3:
Write a program that obtains two integer numbers from the user.
It will print out the sum of those numbers.
1. Prompt the user to enter the first integer
2.Prompt the user to enter a second integer
3.Compute the sum of the two user inputs
4.Display an output prompt that explains the answer as the
sum
5.Display the result
A graphic representation of an algorithm,
often used in the design phase of programming to work out the
logical flow of a program
Flowchart Symbol
Example 1:
• Draw flow chart of an algorithm to add two numbers and
display their result.
Algorithm description
1. Read the two numbers (A and B)
2. Add A and B
3. Assign the sum of A and B to C
4. Display the result ( c)
Flow Char is :
Start
Read A, B
C= A+B
Print C
End
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
Flow Chartt is :
Some times there are conditions in which it is necessary to
execute a group of statements repeatedly. Until some
condition is satisfied. This condition is called a loop.
Loop is a sequence of instructions, which is repeated until
some specific condition occurs.
A loop normally consists of four parts.
A loop normally consists of four parts. These are:
◦ Initialization: - Setting of variables of the computation to
their initial values and setting the counter for determining to
exit from the loop.
◦ Computation: - Processing
◦ Test: - Every loop must have some way of exiting from it or
else the program would endlessly remain in a loop.
◦ Increment: - Re-initialization of the loop for the next loop.
Example -3:
Write the algorithmic description and draw a flow chart to
find the following sum.
Sum = 1+2+3+…. + 50
Algorithm description
1. Initialize sum to 0 and counter to 1
1.1. If the counter is less than or equal to 50
• Add counter to sum
• Increase counter by 1
Repeat step 1.1
1.2. Else
• Exit
2. Write sum
Flow Char is :
depicts the logical functions to the solution of the problem
using a chart.
It provides an overview that confirms the solution to the
problem without excessive consideration to detail.
It is high-level in nature.
Example-1:
Write a program that asks the user to enter a temperature
reading in centigrade and then prints the equivalent
Fahrenheit value.
Input Process Output
Centigrade Prompt for centigrade value Fahrenheit
Read centigrade value
Compute Fahrenheit value
Display Fahrenheit value
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.
The phases of SDLC are :
Feasibility study :
Requirements analysis
Designing solution
Testing designed solution
Testing
Implementation
Feasibility study : The first step is to identify a need for the
new system.
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
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 :
- 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.
The design will serve as a blueprint for the system and helps
detect problems before these errors or problems are built into
the final system.
Implementation
The real code is written here. Systems implementation is the
construction of the new system and its delivery into
production or day-to-day operation.
Testing
◦ Unit Testing
◦ Integrating Testing
◦ System Testing
Maintenance
What happens during the rest of the software's life: changes,
correction, additions, and moves to a different computing
platform and more.
This, the least exciting and perhaps most important step of all,
goes on seemingly forever.