Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

PROGRAMMING LOGIC AND TECHNIQUES

PROGRAM DEVELOPMENT
Program Development is an on going systematic process that extension professional fellow as the plan, implement
and evaluate their programs. As we know that computer program is a set of computer characters, symbols and
instructions. Program is a group of instructions, or a driver and an operator for a computer system which gives the
proper instruction to run it. Program helps to run the computer system in to our desired way. To complete any
programming task we have to complete the step-by-step process. Before designing or writing a specific program we
must plan and point out the programming structure to complete an effective, correct and best program we must first
plan suitably its logics. If we attempt to a specific plan, the logic and writing a program at the same time we are likely
to become so involve with the required instruction formats that program logic will suffers or ambiguities. So, before
writing any program or software we should complete all the step wise process, then we can develop suitable and
effective program. It is a step by step process where each stage is a building block of an effective and efficient
program. A well designed program helps the programmer in understanding the program logic clearly and facilitates
debugging and testing. Therefore, Program development cycle can be divided into several stages. This is also truth
fact all the stages mentioned bellow are generally performed in a specific sequence but in practical work, the
development process goes through a spiral process. So, Programmers follow different stages or steps in a planned
manner to develop the program. The program development cycle (PDLF) consists of the following steps:-
1. Problem Identification
2. Requirement Analysis
3. Input/Output Identification
4. Designing the Solution
5. Data Validation
6. Program Coding
7. Debugging and Testing
8. Implementation and Documentation

1. Problem Identification:
The developer invests lot of time to investigate and analyze the actual problem. The major responsibility of a
programmer is to know the requirement of the system which here he/she going to development. Without finding an
actual problem of the system no one can develop an effective program or software. These requirements are visible
only when the shortcoming of the current system is known. Most of the programs written today from part of the
much larger system and to help a programmer to understand a particular program’s significance, its position in the
entire system should be clear. In this stage analyst states the problem clearly and unambiguously (single
interpretation) to understand exactly:
• What the problem is?
• What is needed to solve it?
• What the solution should provide?
• If there are constraints and special conditions.

2. Requirement Analysis:
The analysis of the particular of those data and tasks that need for the specific program is also the important step of
analysis programming requirements. He/ she must make decisions with respect to the available resources and
requisite data. The programmer need be collected the data and documents about the following facts: what sources
must be provided? How provided? How and which translator program or language processor to be used? Which
coding language can be suitable according to the system? What is layout of the source program? How the files will be
maintained? What will be the size of file? What will be the layout of the computer record data? etc. This is an
important step of program development where the developer collects the data about the need and problem of the

1
Prepared by: N.P.BHUSAL
Email ID: smcnpbhusl@gmail.com
PROGRAMMING LOGIC AND TECHNIQUES
user from the field and analyzes them to get the way of the solution. In the analysis phase, we should identify the
following:
• Inputs to the problem, their form and the input media to be used
• Outputs expected from the problem, their form and the output media to be used
• Special constraints or conditions (if any)
• Formulas or equations to be used

3. Input/Output Identification:
It is the process of converting an external, user oriented description of the inputs to a system into machine-oriented
format. Output identification and specification consists of the fact that which device is using and how we can
maintain and produce the device for the programming document completely, clearly, easily. In other word analysis
of printing devices and the page layout of the program, this task is the program’s output mode. So the programmer
has to knowledge about the devices for outputting documents and screen layout and page layout for the hard copy of
the document or program which to be completed.

4. Designing the Solution:


This is the planning and detailing process of the program. This way programmer can concentrate initially on the
general logic of the individual instructions. It is the stage at which the programmer follows different techniques or
methods to achieve the goal. The developer develops many probable solutions to solve the problem and finally
selects the best solutions. The programmer concentrate on developing the programming logic to get an errorless and
effective programming coding and used many tools such as Algorithm, Flow chart , Decision Table etc. So, Designing
refers to the set of activities that includes defining architecture for the program that specifies the requirements and
specifying an algorithm, Decision table, Flowchart etc. for each program component in the architecture.

5. Data Validation:
This data validation means the checking the entered data is according to the plan or structure of program and
supporting of our system. The interring validation checking defines that the valid code, characters, digits, valid field
size, sing and composition, valid transaction. In this portion the programmer can make order of the data according to
programmer’s demand and architecture. The programmer makes the data requisite of program system validation.
Some techniques are used to check the data validation in a program development :(a) Content (b) Construct (c)
Criteria.
Types of Data Validation:
• Field Level Validation: To make sure that mandatory fields are provided by the user and the rest of the
information generally of the expected type or empty (if any field can be considered optional).
• Form Level Validation: Client information screens and other general information inquiry screens can do
fine with a simple form level validation.
• Data Saving Validation: This type of validation is performed at the routine that will be performing the
actual saving of the information to the file or database record.
• Search Criteria Validation: In this type of validation the strength and capabilities of the program according
to plan and demand of the user can be evaluated maintained.

6. Program Coding:
Coding is the writing process of the program where the algorithms or flowcharts or decision table translated into the
programming logics and instructions using any programming language. The programmer translates the program
logic design documents into a computer language format by using an appropriate programming language. The
language selection for coding depends upon the programmer’s demand and available facilities to the programmer.
Representation of a program in the text mode with help of any available programming language is sometime called
coding. The language of coding is mostly used in the program is English language which understand by the computer.
To represent the designed structure into the computer understandable format by the programmer; he must know
the detail syntax of the programming language which he is using to write a program.

7. Debugging and Testing:


When a program is compiled or executed then it may produce the available errors in the program. The process of
eliminating the bugs and errors is debugging. So, debugging is the process of checking the correctness of the
programs provided with the compiler program of language processor for error handling. There can be various types
of errors occurred in the program such as lexical errors, syntax errors, runtime errors, logical errors , data errors,
documentation errors, operating system errors, database connectivity errors, missing supporting or linked files,
Version support errors etc so, the debugging process remove or correct all the errors and make program correct and
errorless.

2
Prepared by: N.P.BHUSAL
Email ID: smcnpbhusl@gmail.com
PROGRAMMING LOGIC AND TECHNIQUES

A lexical error occurs when the program consists of errors in identifiers, constants or reserved words declaration.
A syntax error occurs when the program violates one or more grammatical rules of the programming language. These errors are
detected at compile time by the translator program. For example: typing PINT place of PRINT statement.
A runtime error occurs when the program directs the computer to perform an illegal operation such as dividing number by zero.
Runtime errors are detected and displayed by the computer during the execution of a program. When a runtime error occurs, the
computer will stop executing the program and may display a diagnostic message that helps in locating the error.
Logical error occurs when a program follows a wrong logic. The translator program does not report any error message for a logical
error. Logical errors can be identified by just looking at the wrong output of the program. Logical errors can only be detected by
thoroughly testing the program.

During the programming, the program perform the own program testing work also. The completed program testing
can be performed by both desk checking and comparing .The testing is the part of the procedure that ensure the
program corresponds with the original specification and that is works in its intended environment. Testing is the
process of checking program to show the errorless program. It is the process of running program with wide variety
of data in order to see if it performs correctly.

DIFFERENTIATION BETWEEN DEBUGGING AND TESTING:


SR. DEBUGGING TESTING
1. Debugging is the process of eliminating errors in a Testing is the process of validating the correctness
program. Its objective is to delete the cause of error of a program; Its objective is to demonstrate the
and remove known errors in the program. program meet its design specification.
2. Debugging is complete when all known errors in Testing is complete when all desired verifications
the program are fixed. against specifications are completed.
3. Debugging being a reactive process cannot be Testing is a definable process that can and should be
planned ahead of time. It is carried out whenever planned and scheduled properly.
errors are deleted in a program.
4. Debugging can begin only after the program is Testing can begin in the early stages of the program
ready. The approach used for debugging largely development.
depends on the personal choice of a programmer
and the type of error in the program.

8. Implementation and Documentation:


The errorless program goes to the user’s computer to solve an actual problem. Problem should contain the features
of desired result i.e. flexibility, easy to use etc. If software cannot provide such features completely, it can be
maintain later also. Human’s desire can not be fulfil; it increases day by day so that the program require maintenance
in time to time. At implementation stage programs are corrected and updated to meet the need of changing
conditions. It should be corrected or modified on the basis of field experience.

When the program exists totally errorless and complete, it should be kept by making document test data.
Documentation means the complete written material of the program or whole records of the program including
flowchart, algorithm, procedure, design, coding methods, source code, testing and proper usage etc. Documentation
is valuable for the users who rely upon the program on a day-to-day basis, and for the programmer who may be
called on to modify or update it. Program documentation has the capacity to sustain any later maintenance or
development of the program. Program documentation includes the hard-copy or the electronic manuals that enable
users, programmer developers and operators to interact successful with a program. The proper documentation of
program helps to the programmer to solve the problem that occur in future and helps for the implement the
advancement in the program which will be developed later. Documentation is the process of collecting, organizing,
storing and maintaining a complete historical record of programs and other documents used or prepared during the
different phases of the life cycle of program development. Documentation has to be carrying out from time-to-time
whenever program is modified during its maintenance phase. Forms of documentation can be comments, system
manual, user manual etc. In general, comprehensive documentation consists of the following:
• A description of what the program is supposed to do (software requirement document)
• A description of the problem solution (the algorithm)
• A description of the program design, including any aids used (Flowcharts, algorithms etc.)
• A description of the program’s testing program’s testing process, including the test data used and results
obtained.
• A description of all corrections, modifications, and updates made to the program since it was put into operation.
• A user manual (User guide).

3
Prepared by: N.P.BHUSAL
Email ID: smcnpbhusl@gmail.com
PROGRAMMING LOGIC AND TECHNIQUES
SOME PROGRAM DESIGNING TOOLS:
1. Algorithm
2. Flowchart
3. Pseudo code
4. Decision Table
5. Decision Tree
6. Data Flow Diagram (DFD)
7. Entity-Relationship Diagram(E-R Diagram)

ALGORITHM:
Algorithm is the important tool for the program development or software development. Algorithm is the step by step
sequence of well defined instructions to solve the problems of a program in a finite number of times and that can be
written in any programming language. The word ”Algorithm” is derived from the phonetic pronunciation of the last
name of Abu Ja'far Mohammed ibn Musa al-Khowarizmi (which means a method, technique or a procedure) by 18th
century, who was an Arabic (Muslim) mathematician who invented a set of rules for performing the four basic
arithmetic operations (addition, subtraction, multiplication and division) on decimal numbers. It is a step by step
description of the logic of a program in a correct sequence. It is a set of procedure or design of plan of obtaining a
solution to the problem. An algorithm is the plan for writing a program. It is a logical process of analyzing a
mathematical problem and data. It can be written in any computer language or human oriented language. It is a tool
for efficient program development which make to easier understanding and implement solution to the problem of
the program. Writing algorithm for solution of a problem is a method of successive iterations also. Algorithm is first
roughly estimated and written. Then it is carefully gone through a number of times and refined each time. Algorithm
tools make program solutions more clear, more understandable, and easier to remember. Algorithms are written
according to rules so that other programmers are also able to read and understand the solution easily. There are
many Algorithm tools in use, but the most popular ones are Flowcharts and Pseudo-Codes. In this course for all
problems we will use both of these tools but in general you choose only one. The instructions of an algorithm can be
written in plain English language. It is a logical process of analyzing a mathematical problem and data. After writing
algorithm of a program to solve any problem only then that converted in to the computer understanding format or
computer language.

Properties of Algorithm:
• An Algorithm should have one or more input.
• An Algorithm should produce desired output.
• An Algorithm should have finite number of steps for solving problem.
• All the instructions must be accurate and clear of an Algorithm.
• An Algorithm should be programming language independence.
Features of Algorithm:
• Simple and easy to understand and unambiguous.
• Common for every programming Language.
• Accurate result processing way.
• The steps of algorithm perform for a number of finite times only.
• Makes easier to understand complex problems.
• Makes easier to express / convert the problems into program code.
• It makes easy to locate and remove errors and bugs.
Disadvantages of Algorithm:
• It is time consuming process.
• Difficult to represent complicated and complex problems.
• It is not compulsion to write the algorithm to solve any programming problem.

EXAMPLE 1: Algorithm to calculate Circumference and Area of circle.


Step:1 Start
Step:2 Input Radius as Variable R
Step:3 Assign value 3.14 to variable P
Step:4 2 multiply with P and with R and Assign to C
Step:5 P multiply with square of R and Assign to A
Step:6 Display C and Display A
Step:7 Stop
4
Prepared by: N.P.BHUSAL
Email ID: smcnpbhusl@gmail.com
PROGRAMMING LOGIC AND TECHNIQUES
EXAMPLE:2 Develop an algorithm for converting given temperature in Celsius scale into
Fahrenheit scale.

Step:1 Start
Step:2 Input Celsius scale as Variable C
Step:3 1.8 multiply with C and add 32 and Assign to F
Step:4 Display F
Step:5 Stop

EXAMPLE: 3 Write an algorithm to check the number is odd or even.


Step : 1 Start
Step : 2 Input a number N
Step : 3 Is N MOD 2=0
If Yes: Go to Step 4
No: Go to Step 5
Step: 4 Display N is Even.
Step: 5 Display N is Odd.
Step: 6 Stop

FLOW CHRT:
Flow chart is a step by step symbolic and graphical representation of a program to solve a problem that used for
reduce the complexity of writing the programming code by the programmer. It is the best method of designing the
solution about program. It expresses the algorithm by using different symbols. It is designed before the coding of
program. Flow charts are drawn by the programmer to reduce the complexity of writing the code of the problems. If
perfect flow chart drawn, it provides the excellent and perfect guide for writing the program. Flow chart is step by
step diagrammatic representation of the various steps involved in the solution of a problem. It is also indicates the
direction of the flow of the process, relevant operations and computations, points of decisions and other
informations which are the part of the solution of the problem. Flowchart uses boxes of different shapes to denote
different types of instructions. The actual instructions are written within these boxes using clear and concise
statements. These boxes are connected by solid lines having arrow marks to indicate the flow of operation, that is,
the exact sequence in which the instructions are to be executed. Since a flowchart shows the flow of operations in
pictorial form, any error in the logic of the procedure can be detected easily. Once the flowchart is ready, the
programmer can forget about the logic and can concentrate only on coding the operations in each box of the
flowchart in terms of the statements of the programming language. This will normally ensure an error-free program.
A flowchart is basically the plan to be followed when the program is written. It acts like a road map for a
programmer and Flowcharting Concepts and Algorithms guides him in proceeding from the starting point to the final
point while writing a computer program. Flow charts are used for broad variety of applications in different types of
work.They are a convenient to used in administrative file handling as in scientific or engineering , computation.
There are mostly two types of flowcharts used in computer system:
1. System Flow Chart
2. Program Flow Chart

A System flowchart gives systematic information about the program including many modules together. It is a general
purpose flowchart which is popularly used by a system analyst while developing a new system. A System flowchart
describes the sequence of operations and decisions for a particular program.

5
Prepared by: N.P.BHUSAL
Email ID: smcnpbhusl@gmail.com
PROGRAMMING LOGIC AND TECHNIQUES
Program flowchart is used by a programmer before developing the programs. It shows in the sequences of
instructions by using some different symbols. Program flow charts are sometimes referred as block or logic
diagrams. Program flowcharts are usually the most convenient methods of preparing the descriptions of computer
programming procedures.

Some symbols used in Flowchart:


• Elongated circles: This is also called terminal symbol that used to indicate the beginning (start), ending
(stop) and pauses (halt) of a process in the program logic flow.

Start / End

• Input/Output: An Input/Output symbol issued to denote any function of an input or output


device in the program.

• Rectangles: This is a processing symbol that is used to represent arithmetic and data movement
instructions which show instructions or actions.

• Diamonds: Which show decisions that must be made i.e. this symbol used to indicate a point at
which a decision has to be made and a branch to one of two or more alternative points is
possible.

• Connector/Circle: Connects one part of the flowchart to another part of the flowchart on the
same page using matching symbols.

• Flow lines: Flow lines with arrow heads are used to indicate the flow of operation that is
the exact sequence in which instructions are to be executed.

Advantages of Flowcharts:
• Flow charts give a clear graphical or pictorial representation of the various paths that must be
performing the acts to accomplish the goals of the program.
• Flowcharts are language independent.
• Flowcharts are constraining and precise in ways that are useful to programmers and analysts.
• Flowcharts are visual representation, and hence provide a convenient alternative to usual
narrative description for a program system.
• Flowcharts offer a controllable level of detail.
Disadvantages of Flowcharts:
• The programmer must be remembering about the functions of each symbol.
• Flowcharts are difficult to produce at a summary level.
• Flowcharts are often cumbersome to use and costly to produce because of their graphic format,
they may devote more than a half- page or a page.

EXAMPLES: (A) Flow chart to calculate circumference and area of circle.


6
Prepared by: N.P.BHUSAL
Email ID: smcnpbhusl@gmail.com
PROGRAMMING LOGIC AND TECHNIQUES
(B) Flow chart to calculate Celsius temperature to Fahrenheit temperature.

3. Pseudo code:
Pseudo code is another program-planning tool used for planning program logic. “Pseudo” means imitation or false
and “Code” refers to the instruction written in a programming language. Pseudo code, therefore, is an imitation of
actual computer instructions. These pseudo-instructions are the phrases written in ordinary natural language (e.g.,
English, French, German, etc) that a computer cannot understand.

When the programmer uses pseudo code for program planning, he/she can concentrate solely on developing the
logic of the program without worrying about syntax for writing the program instructions because pseudo code do
not have any syntax rules for formulating instructions. Once the programmer is convinced that the program logic is
sound, he/she can easily convert the pseudo code into suitable programming language. Since pseudo code emphasizes the
design of a program, it is also known as Program Design Language (PDL).
Advantages of Pseudo code:
1. As compared to a flowchart, converting a pseudo code to a programming language is much easier.
2. As compare to the flowchart, it is easier to modify the pseudo code of program logic when program modifications
are necessary.
3. Writing of pseudo code involves much less time and effort than drawing an equivalent flowchart.
4. Moreover, as compared to writing a program in an actual programming language, pseudo code is
easier to write because it has only a few rules to follow, allowing a programmer to concentrate on the logic of the
program.
Limitations of Pseudo code:
1. In case of pseudo code, a graphic representation of program logic is not available.
2. There are no standard rules to follow in writing pseudo code. Different programmers use their own style of
writing pseudo code. Hence, communication problem occurs due to lack of standardization.
3. For a beginner, it is more difficult to follow the logic of pseudo code or write pseudo code as
compared to flowcharting.

Example: 1 Pseudo code to calculate sum of any two numbers:


• Step:1 Start
• Step:2 Input A,B
• Step:3 C=A+B
• Step:4 Print C
• Step:5 End

7
Prepared by: N.P.BHUSAL
Email ID: smcnpbhusl@gmail.com
PROGRAMMING LOGIC AND TECHNIQUES
Example: 2 Pseudo code to convert temperature from centigrade to Fahrenheit.
• Step:1 Start
• Step:2 Input C
• Step:3 F=((9*C)/5) +32
• Step:4 Print F
• Step:5 End

Example: 3 Pseudo code for asking any two numbers and find out the largest one.
• Step:1 Input a, b
• Step:2 If a>b
G=a
Else
G=b
End if
• Step:3 Print “largest number is”;G
• Step:5 End

DECISION TABLE:
Decision tables are graphical method for describing the logic of the specific condition. A Decision table lists a set of
conditions and a set of actions and identifiers different combinations of decision that lead to different combinations
of action in a tabular format. A Decision table is a simple table which is used to show the various actions to be taken
for different combinations of different conditions. This table specifies the logical rules. Decision table is a
programming and analysing tool which is useful in the analysis of rules, regulations and procedures with the
probable results. Decision table do not describes about the total program but it involves with the certain part of the
logic, decisions, and conditions in the program. In this tool logical information is captured in tabular form and it is
also another useful tool like flow chart, algorithm for the efficient, clear, programming.
Some elements of Decision Table:
1. Condition Stub
2. Condition Entry
3. Action Stub
4. Action Entry

The condition Stub and condition entry describes the conditions and decisions to be related while the action entries
concern the actions to be taken. We can see the layout of the Decision table that consists of four elements as form
quadrants.
Condition Stub Condition Entries
Action Stub Action Entries
The table lists all the conditions relating to a procedure, one blow other, in the condition stub. The action stub lists
all possible actions. The conditions entries together constitute one or more rules, which run vertically through the
two right hand quadrants. Each rule indicates the actions needed when a particular of condition applies.
Some application areas of Decision Table:
 Business Analysis
 Programming
 Testing
 Hardware Design etc.
Advantages of using Decision Tables:
 The Decision table provides a framework for a complete and accurate statement of processing or decision
logic and procedures.
 It is useful to summarization of information in documentation.
 The table allows good programming task mechanism.
 It can be easily understand by the analyst, programmers and others.
 Larger decision tables can be split and linked together so, provides convenient way of tersely state logically
complex problem.
 The procedure for creating decision table provides rules which helps to remove possible errors.
Disadvantages:
 Do not reduce the human labour of thinking or discovery. People still must do detailing work.

8
Prepared by: N.P.BHUSAL
Email ID: smcnpbhusl@gmail.com
PROGRAMMING LOGIC AND TECHNIQUES
 Decision table ignores the delicate interleaving of logic and action that seems so natural when people think
as conditions and actions to be taken.

EXAMPLE:1
Decision table for describing the Servicing of Car with conditions: ‘is petrol low? ’is oil low?’
Solution:
Here, These given two conditions about the Servicing of car topic leas to four possible combinations:
 Both petrol and oil are low
 Only petrol is low
 Only oil is low
 Neither is low
Each of activities will result in a different activity:
 Get both petrol and oil.
 Get petrol only.
 Get oil only.
 Do not get anything.

Decision Table for above conditions


Conditions Rules
1 2 3 4
1. Is petrol low Y Y N N
2. Is oil low Y N Y N

Actions
1. Get Petrol X X
2. Get Oil X X
3. Not Get X

EXAMPLE:2
Decision table for describing the organizational salary increment according to different conditions.
1. No increment is given to those employees who’s salary already 50,000 or more.
2. 10% increment is given to those employees who’s salary between 30000 and 50000.
3. 15% increment is given to those employees who’s salary less than 30000.

Decision table for describing the organizational salary increment


Conditions Rules
1 2 3 4 5 6 7 8
Cond:1 Salary>=50000 Y Y Y Y N N N N
Cond:2 Salary>=30000 & Salary<50000 Y Y N N Y Y N N
Cond:3 Salary<30000 Y N Y N Y N Y N
Actions
Actn:1 No increment X
Actn:2 10% increment X
Actn:3 15% increment X
Actn:4 Not Possible X X X X X

DECISION TREE:
The decision tree defines the conditions as a sequence of left to right tests. Thus it shows which conditions to
consider first, which second and so on. It is also a method of showing the relationship of each condition and its
permissible actions. A decision tree helps to show the paths that are possible in a design following an action or
decision by the user. In Figure (which drawn below) illustrates the concept of decision tree. It is a decision
support tool that uses a tree like graph or model of decision and their possible consequences. Decision tree are
commonly used in operation research especially in decision analysis to help identify a strategy, plan or policy
most likely to reach a goal. Decision tree is a descriptive for calculating conditional probabilities.
Advantages of Decision Tree:
9
Prepared by: N.P.BHUSAL
Email ID: smcnpbhusl@gmail.com
PROGRAMMING LOGIC AND TECHNIQUES
1. They are simple to understand and interpret.
2. Data preparation for a decision tree so basic.
3. It is able to handle all types of data.
4. It is used to white bound model. If a given situation is observable in a models the explanation
for the condition is easily explained by Boolean logic.
5. It is possible to validate a model using statically test.
6. It is robust and strong performs well with large data in short time.

10
Prepared by: N.P.BHUSAL
Email ID: smcnpbhusl@gmail.com

You might also like