# Programming Tools

The programming is a solution of different problems of our real life. If efficient programming tools are used, problems are effectively solved. We code some instructions to instruct computer for problem solving purposes. The choice of tools depends on nature of problems.

There are many tools for programmers for programming. For instance, algorithms, flowcharts, pseudocodes, data dictionary, decision table, data flow diagrams etc are effective tools. Enough and adequate knowledge of programming tools are essential for programming (Software development).

### 1. Flowchart

The pictorial presentation of program is called Flowchart. It is a tool and technique to find out solution of programming problems through some special symbols. It is a way to represent program using geometrical patterns. Prior to 1964, every manufactures use different types of symbols, there was no uniformity and standards of flowcharting. The Standard symbols were developed by American Standard National Institute (ANSI).

There are two types of Flow Chart:

(a) Program Flow Chart and

(b) System Flow Chart.

Flow Chart

(i) Start / Stop: This oval is used to represent START and STOP of program.

(ii) Input/Output: Parallelogram is used to denote input and output of data. We take data through it and display result also using this symbol.

(iii) Process: Rectangle is used to denote process, formula, increment, and decrement and assigned value also.

(iv) Pre-defined Process: The predefined process is denoted by this symbol. Example: Sorting and Display is pre-defined process and represented as:

Pre-defined Process

(iv) Decision box: It is a symbol of decision. All type of decisions is written in it.

(v) Connector: It is used to link to segment of flowchart to complete as one.

(vi) Data flow: It is used to show data flow from one component to other component, one process to other and one symbol to other symbol.

The John Von Neumann used flowchart to solve problem in 1945 and explained its importance in program designing.

Illustration: In our everyday life, there is a sequence of works. These sequences of works are called routine. We all are tied with it. Suppose, we arise early in the morning at 5 0’ clock, go to toilet, after coming from toilet, clean hands with soap and water, brush our teeth then take bath. Here, one sequence of work is formed.

In computer world, programming language is used to solve certain problems. The solution of problem is a sequence of processes. In one problem, there may be many processes, the flowchart help to arrange processes in definite order. Suppose, we have to convert Fahrenheit temperature into Celsius, it has following five steps:

• Step-1: Start
• Step-2: Enter Fahrenheit temperature (F)
• Step-3: Application of formula: C=(F-32)(5/9)
• Step-4: Displaying the result (C)
• Step-5: Stop

These types of processes involved in solution of problem are called Algorithm. It is a stepwise presentation of problem solution in simple English without using confusing words and phrases.

When we draw flowchart, it is only conversion of steps or algorithm in special symbols.

FLow Chart

Flowchart is like as city map. Travelers or tourists search places of historical importance through city map. Buildings are built on the basis of building-design (map) drawn by Architect engineers.

Just like it, program is coded on the basis of flowchart. Flowchart is a language free concept, if it is prepared, any language can be used for program coding. In software development cycle, flowcharting is one essential phase.

#### System Flowchart:

System flowchart is a pictorial representation of procedure flows inside and outside of the systems. It is also called Data Flow Chart or Procedure Chart.

System Flowchart Symbols

(i) Manual Input: It is used to enter data manually. For example, keyboard is a manual input device.

(ii) Process: All type of processes is denoted by Rectangle.

(iii) Magnetic Disk: Mass storage device (Hard Disk).

(iv) Magnetic Tape: Magnetic tape is also storage device.

(v) Display: This is a symbol for online display, Example: Monitor (VDU).

(vi) Document: The print out document is denoted by this symbol.

Program Flowchart and System Flowchart:

 Sn. Program Flow Chart System Flow Chart 1. The pictorial presentation of program is called Flowchart. It us a tool and technique to find out solution of programming problems through some special sysmbols. It is a way to represent program using geometrical patterns. System flowchart is a pictrorial representation of procedure flows inside and outside of the systems. It is also called Data Flow Chart or procedure Chart. The special type of symbols is used to represent system flowchart. 2. It is tool of programmers. The flowchart designing to solve any problem is called program flowchart. The candidate system is designed using program flowchart. This is a flowchart to show data flow inside or out to designed system. The system designers draw it to show data flow inside the current system.

Problem-1: The source program is stored in hard disk and after compilation; the object program (Machine code) is also stored in hard disk. The rectangle represents compilation process. The error messages are printed out and displayed on VDU also.

Compilation Process

Problem-2: Draw a system flow chart to update master-file.

System Flowchart to update master file

Problem-3: The headquarter of ABC Private Ltd. is linked with production, marketing and sale department. The day-by-day information of each department is compiled at headquarter, stored in master file and report is given to higher authority of company.

### 2.  Algorithm

Algorithm is a stepwise presentation of procedures of program in simple and phraseless English. It is also a programming tools used by programmer to develop software. It is a logical representation of program procedures in order to obtain result. So, sometimes, it is called Procedure also. An algorithm, named after the ninth Centaury scholar Abu Jafar Muhammad Ibn Musa Al-Khowarizmi of Bagdad (Iraq).

A program is an expression of an idea in any programming language. A programmer starts with a general idea of a task for the computer to perform. The problem is flesh out the outline into a complete, unambiguous, step-by-step procedure for carrying out the task. Such a procedure is called an ”Algorithm“. An algorithm is not same as program. An algorithm is more like the idea behind the program.

• Language independent
• Simple, complete, unambiguous, step-by-step program flow
• no standard format or syntax for the algorithm
• helpful to understand problems and plan out solution

Example: Following algorithm is written to find out roots of quadratic equations:

• Step-1: Start
• Step-2: Read a,b and c
• Step-3: d=b*b-4*a*c
• Step-4: if D<0, root is imaginary
• Step-5: x1 = (-b + sqrt (D))/(2*a)

X2=(-b-sqrt(D))/(2*a)

• Step-6: Display x1 and x2
• Step-7: Stop

Example: Write an algorithm to find out area of triangle when sides are given.

Algorithm:

Step-1: start

Step-2: read a,b and c

Step-3: S=(a+b+c)/2

Step-4: A=sqrt((s-a)(s-b)(s-c))

Step-5: Display A

Step-6: Stop

Example: Write an algorithm to find out slop and mid point of coordinate.

Algorithm:

Step-1: Start

Step-2: Read x1, x2, y1 and y2

Step-3: Slop=(y2-y1)/(x2-x1)

Step-4: x-(x1+x2)/2

Step-5: y=(y1 + y2)/2

Step-6: Stop

There are no standard rule for algorithm designing, but we can use some common rules which are not ambiguous to another computer literates:

(a) Value to variable: variable (Variable or Expression)

(b) Conditional statements: if -endif and if –else-end-if are used for conditions.

Example:

If age>=18 then print “Case vote”

Else print “Wait until not 18”

Endif

(c) looping statements:

i. do while (condition)

Statement(s)

endo

ii. for variable=value1 to final value step stepvalue

statement(s)

endfor

Example: Write an algorithm to display factrolial of given number.

Fact = 1

Print “Enter number”

For count =1 to count number step 1

Fact = fact * count

Endfor

Print “Factorial:”, fact

End

Problem-1: Draw a flow chart to input two numbers and display sum.

Flow Chart to display sum of two numbers

Problem-2: Draw a flowchart to enter principal,rate and time and display simple interest.

Flowchart to Calculate Simple Interest

Problem-3: Draw a flowchart to find the sum of the given series.

$\dfrac{1}{x} + \dfrac{3}{x^2} + \dfrac{5}{x^3} + \cdots$

Solution,

Flow Chart to find sum of series

### 3. Pseudocode or Structured English

A logical construction, which has

(a) no strict rules like as programming language,

(b) unambiguous statements,

(c) Phrase less statements, contains noun and simple verb of English , and

(d) no adjective and adverbs structure is called Pseudocode or Structured English.

It is a Program Design Language (PDL) provides skeleton for program design and it can replace flowchart used to describe system design.

General rules used in writing Pseudocodes are as follow:

(i) Imperative Sentence: The imperative sentences are used to show actions.

Example: Add x to sum, Display result, Sort list etc.

(ii) Operators: Mostly arithmetic operators (+, -, *, / etc) and relational operators (=, =>, =>, <, > etc.) are used.

(iii) Decision: IF, THEN, ELSE, ENDIF, CASE, ENDCASE are used for decision-making.

Example:

CASE (choice)

(Choice = 1):Display Employee, Department

(Choice = 2): Display Employee, BasicSal, Allowance, Gross

(Choice = 3): Terminate Program

ENDCASE.

(iv) Looping: The looping or repetition of statements is shown by FOR, FOR DO, ENDFOR, DO, DO WHILE, DO UNTIL, ENDDO etc.

Example:

Display “Selected for National scholarship Examination”

FOR roll1 TO roll=10 DO

Display roll, Name, Address

ENDFOR.

Example:

IF age >=18

THEN CASTE vote

ELSE

WAIT until age is not 18

ENDIF

Example: Mailing a letter

BEGIN

WRITE a letter

IF bicycle is available

THEN GO to Post Office by Bicycle

ELSE

GO to Post Office on foot

ENDIF

STICK a stamp on the letter

PUT into letterbox

END.

### 4. Decision Table

A decision table defines a logical procedure by means of a set of conditions and related actions. It is used for communicating and documenting complex decision procedures.

Procedure: The decision table is divided into four quadrants: Condition stub, Condition entry, Action stub, and action entry. The conditions are answered as Y (yes) or N (No). The blank space shows that the condition involved has not been tested. X (or check marks) represents response to the answer.

 Condition Stub             C1                                         C2                                          -                                         Cn R1     R2      R3    R4 Condition entry Action Stub                            A1                                                A2                                                 -                                                An Action entry

Problem: The policy followed by an ABC Ltd. to process agents’ orders is given by the following rules:

(i) If the customer order <= that in stock and his credit is OK, supply his requirement.

(ii) If the customer credit is not OK, do not supply. Send him intimation.

(iii) If the customer credit is OK but items in stock are less than his order, supply what is in stock. Enter the balance to be sent in a back-order file.

Decision Table:

 Order <=Stock Credit OK Y Y N N y N Y N A1: Supply order   A2: Credit not OK   Pay cash   A3: Supply Stock   A4: Enter (order-Stock) in back order file X -   -   -   - -   X       -   - -   -       -   - -   X       -   -

Problem: Create a decision table to decide whether on a given data a student in an University has completed 3 years of enrolment or not.

Decision Table:

Let data enrolment Dj – Mj – Yj (day-month-year) and current date is Dt – Mt – yt (say – Month –Year)

 If (Yj – Yt) If (Mj – Mt) If (Dj – Dt) >3     =3       =3 -         >0      =0 -          -        >=0 Else 3 years enrolment? Y          Y       Y N

Problem: The Delta gas company bills its customers according to the following rate schedule:

(i) First 500liters Rs. 50 (flat)

(ii) Next 300 Liters Rs. 5.25 per 100 liter

(iii) Next 30,000 liters Rs. 2.50 per 100 liters

(iv) Above this Rs.2.00 per 100 liters.

The input record has customer identification, name and address, new meter reading, past and present. Create decision table to obtain bill for customers.

Decision Table:

Charge table:

 Consumption <=500 501 to 800 801 to 30800 >30801 Go To C1 C2 C3 C4

C1: Charge=50

C2: Charge=50+ (consumption-500)*0.0525

C3: Charge=65.75+ (consumption-800)*0.0250

C4: Charge=815.75+ (consumption-30800)*0.02

Problem. A bank has the following policy on deposits: on deposits of Rs. 25000 and above and for three years or above the interest is 10%. On the same deposit for a period less than three years it is 8%. On deposits below Rs. 25000 the interest is 6% regardless of the period of deposit. Write the above process using

(a) Structural English

(b) A decision Table.

Solution

(a) for each deposit do

If deposit>=25000

Then if period>=3 years

Then interest=10%

Else interest=8%

Endif

Else interest 6%

Endfor

(b) Decision table:

 Deposit>=25000 Y Y Y N N - Interest % 10 8 6

### 5. Decision Tree

The tree like presentation of condition and actions are called decision tree. Every node denotes conditions. It is used for logical variations and problems involving few complex decisions with complex branching routines.

Example: The person which age is greater or equal to 18 can caste vote in the favour of his leader otherwise has to wait until age of 18. There is two conditions (a)age<18, and (b)age>=18, both the conditions have actions.

Decision Tree

Example: The hotel ABC offers new discount scheme foe university students. It provides 15% and 10% discount to monthly customers for vegetarian and non-vegetarian meal respectively. The student attend hotel occasionally have discount rate 10% and 5% for vegetarian and non-vegetarian meal.

Draw decision tree to show discount scheme:

Example of Decision tree

Related posts:

1. Programming Concepts Step of Programming   The programming is the coding instruction...
2. Procedural oriented programming Procedural oriented programming (pop):- A program in a procedural language...
3. Programming Language Language is a medium of communication. There are several languages...
4. process model The software and large program is organized into a number...
5. Object oriented programming Object oriented programming : The main idea behind object oriented...