Professional Documents
Culture Documents
Programming Logic
Software has characteristics that are considerably different than those of hardware:
1. Software is developed or engineered; it is not manufactured in the classical sense.
2. Software doesn’t wear out, but it does deteriorate.
3. Although the industry is moving toward component-based construction, most software
continues to be custom built.
Step 1: Defining and Understanding the Problem: This process mainly deals with the analysis
of the problems. During this step, the developer carries out a number of tasks aimed at producing
a document which spells out the input, process and output requirements. The tasks involve:
Collecting information from the client, to identify and verify the user’s needs
Determine the scope of the problems to be solved and define its boundaries clearly
Examining feasibility issues
Identifying and considering the social and ethical requirements.
Analyze the input, output and processing requirement.
Step 2: Planning and Designing Software Solutions: Developers take the information
presented in Stage 1 of the Program Development Cycle and use it to design a solution.
Designing a Solution involves:
Documenting the names and data types of all the data elements used in the form of a
Data Dictionary.
Using Abstraction and Enhancement techniques to develop Modularized Solutions.
Developing Algorithm Solutions with flowcharts or pseudocode.
Using Structure Charts, Data Flow Diagrams, or System Flow Charts to show the
relationship between Modules or processes.
Designing Test Data to test the solution.
Step 4: Testing and Evaluation of Software Solutions: Testing is the process of making sure
that the software solution meets all the defined requirements. Evaluation has more to do with
Quality Assurance and examining what people think of the solution measuring its functionality,
user friendliness, flexibility, probability etc. Testing can take place on a number of different
levels including: The module level, program level, system level, user level etc.
Once the algorithm is ready, it becomes ready and easy to code program. In fact, algorithm and
flowchart is a roadmap to solution of the program. Flowchart is descriptive solution of the
problem where as flowchart is the pictorial solution of the problem. Let us analyze algorithm and
flowchart separately.
A. Algorithm
Algorithm is a set of instruction which will produce a solution to a given problem is executed
in a specified sequence. An algorithm tells a person what to do next. Thus, an algorithm is a
roadmap for solving a problem. The word ‘algorithm’ is named after a famous ninth century
Arabic author and mathematician Abu Jafar Mohammed Ibn Musa Al Khowarizmi.
In any solution of problem, a programmer would usually have a choice of algorithms and
each algorithm has its own advantages and limitations but important job is that to decide
which algorithm is best. On solving the problem we must write the instruction in such a way
that the computer can easily execute it.
Let us understand the concept of algorithm by taking a simple example. You must have heard
a recipe for making an omelet. The recipe tells the stepwise instructions to make omelet as:
You have an omelet. Yes the sequence of stepwise instructions to make omelet is an
algorithm. It would be better to understand the concept of an algorithm with a proper
example.
Example 2:
Write an algorithm to add any two numbers.
Step 1: start
Step 2: read two numbers from user
Step 3: assign these numbers in two variables x and y.
Step 4: add the value of x and y put the result in third
variable z.
Step 5: display the value of z.
Step 6: stop.
This is the set of stepwise instructions (algorithm) to add any two numbers. But honestly
speaking, the above example-2 is an informal algorithm. It is not necessary to write an
instruction in a language if arithmetic expression is possible, i.e. instead of “read two
numbers from user----assign these numbers in two variables x and y”, it would be better to
write “read x and y”. Similarly instead of writing “add the value of x and y and put the result
in z” we can write its equivalent arithmetic expression as “z= x + y” as shown in following
example.
Step 1: start
Step 2: read x and y
Step 3: z=x + y
Step 4: print “z”
Step 5: stop.
Example 3:
Write an algorithm to find area and perimeter of a rectangle and area and circumference of
the circle.
Step 1: start
Step 2: read Length (L), Breadth (B), radius (R)
Step 3: A1=L*B
P=2*(L+ B)
A2=3.14*R*R
C=2*3.14*R
Step 4: display the value of A1, P, A2 and C
Step 5: stop
Example 5:
Write an algorithm to find the area of the triangle when three sides are given.
A flowchart uses different graphical symbols to denote different types of instructions. The
instructions are written inside these special symbols. The graphical symbols are connected by
solid lines having arrow marks to indicate the flow of operation.
Symbol Explanation
Start and end of the program is denoted by the oval
symbol.
Processing or mathematical operations are represented
by rectangle.
The parallelogram symbol indicates the input and output
operation.
This symbol indicates the decision making. It allows the
program for branching an looping.
Rules to be considered
While drawing the flowchart, we should consider the following rules or guidelines:
The default flow of direction is from top to bottom and left to right.
Arrow head should be used to indicate the direction of flow or the sequence of
operation.
Only one flow line can enter a processing symbol, decision symbol and termination
symbol.
Do not intersect the flow lines as far as possible.
Make your flowchart clear, logical and neat.
Test the validity of the flowchart by taking some sample data.
Algorithm
1. Start
2. Initialize variable i and Fact
to 1
3. Input any positive number
and read on N
4. Multiply Fact and i, the
result store on Fact
5. Increase i by 1
6. If i <= N then go to step 4
7. Otherwise, print the value of
Fact as output
8. Stop
Limitations of flowcharts:
A professional programmer thinks that drawing a flowchart is a time consuming process.
Drawing a flow chart is wastage of time for a professional programmer because without
drawing a flowchart they can think the logic solve a problem. Any change (even a small
change) in already existing flowchart requires a completely new flowchart. Oops, redrawing a
complex flowchart is tedious, time consuming, and boring task.
One can misunderstand the flowchart if the proper symbol is not used and hence results
a wrong program.
Complex logic: Sometimes, the program logic is quite complicated. In that case,
flowchart becomes complex and clumsy.
Alterations and Modifications: If alterations are required the flowchart may require
re-drawing completely.
All the logic of vary large program cannot be represented by flowchart.
C. PSEUDOCODE
Pseudocode is a famous programming analysis tool which is very close to the program.
Pseudo means false and code means command or instruction. Therefore pseudo code means a
false code. Here false does not mean wrong. The code which is exactly not real code in a
particular programming language but looks like a program is the real meaning of pseudo
code. Pseudo code consists of code which is not exactly the instructions of a particular
programming language. Pseudo code consists of codes that look like a programming
language instructions. Pseudo codes are phrases written in ordinary natural language (eg
English, Japanese etc). The pseudo code is not Set sum to zero
recognized by a computer because they are not Set I to 1
written in a computer language. The main Level 1
advantage of writing a pseudo code is that a Add I to sum
programmer can replace the written pseudocodes Increase I
in language independent way. Figure shows a IF I<=10 THEN GOTO LEVEL 1
pseudo code to find the summation of natural Print the value of sum
number 1, 2, 3, 4……..10. End
Limitations of Pseudocode
Since pseudo code is not recognized by computers. Therefore it is not for computers. It
means a pseudo code cannot be submitted to computers. Computer cannot execute a
pseudo code.
There are no any fixed and standard rules to write a pseudo code. Different
programmers use their own style of writing pseudo code. Hence one can misunderstand
the pseudo code written by the other programmer.
Most of the professional, programmer can develop the logic of the program without
going through pseudo code. So they think writing a pseudo code is a useless step.