Programming tools and techniques
Testing and debugging
- Testing is the process of making sure that the program performs the intended task.
- Debugging is the process of locating and eliminating programs. The process of detecting,
locating and correcting errors/ bugs is called debugging.
Syntax and semantics
- Syntax is the set of rules.
- Semantics is the meaning attached to the individual words or symbols in the programming
language.
Error (Bug)
Errors are the mistake in the program. The error can be in syntax or logic (concept/idea) of the
program.
Different types of error are
a. Syntax error
Syntax error is an error in the syntax or format of the program.
For example: printf(hello world)
Here, double quotes and semicolon (;) is left to assign. So, it has syntax error.
b. Semantic error
Semantic/logical error is an error in a logic/concept/idea of the program that causes it to operate
incorrectly but not to terminate the program abnormally.
For example: printF(hello world)
Here, Capital F in the printf gives different meaning.
c. Run time error
When a program is running or executing, it is said to be runtime. A runtime error is an error that
happens while the program is executing. For example, a memory leak, where the program takes
up excessive amounts of system memory also a runtime error.
Design of Program
- Computer program is the most complex product of human imagination.
- Computer program is a set of instructions needed to solve a problem, written in a language that
the computer can understand.
- Computer program are written with the help of algorithm, pseudocode and flowchart.
Some of the important characteristic of a good are listed below:
1. The program should be user-friendly.
2. The program should be portable i.e., it should be able to run on different platforms.
3. The program should produce accurate results quickly and should use the least amount of
memory.
4. The program should have a self-documenting code.
5. The program should produce accurate results quickly for any set of input data.
Programming tools and techniques
Algorithm
- Algorithm is defined as a set of well defined steps for performing a task or solving a problem.
- It generally takes some input, carries out a number of effective steps in a finite amount of time,
and produces some output.
- The success of a program depends largely upon the clarity and efficiency of algorithm.
The advantages of algorithm are listed below;
1. They are simple to understand and provide a step-by-step solution for a program.
2. Errors can be pointed out very easily. Debugging is simple.
3. They do not depend on any of the programming language.
4. They are compatible with computer language.
Flowchart
- Flowchart is a graphical representation of logical sequence of steps involved in solving a
programming problem.
- It consists of standard set of symbols of different shapes which are connected by arrows.
- Each symbols represents a specific kind of activity and arrows which join these symbols are
called flow lines.
- The flow lines indicate the sequence of the steps and flow of information in a program. The
advantage of flowchart are;
1. Flowcharts are better way of communicating the logic of a system to all concerned.
2. Flowcharts act as a guide or blueprint during the system analysis and program development
phase.
3. Flowcharts help in debugging process.
4. Flowcharts serve as a good program documentation, which is needed for various purposes.
5. The maintenance of operating program becomes easy with the help of a flowchart. It help
the programmer to put efforts more efficiently on that chart.
6. Flowchart help to detect deficiencies in the problem statement.
Programming tools and techniques
Flowchart symbols
Flowchart structures
Generally, there are flowchart structures. They are sequence structure, decision structure and
repetition structure.
A. Sequence structure
The sequence structure consists of operations that are being executed sequentially. It consists of
input, process and output step. For example, if there are three steps A, B and C, then these are
executed in sequence- A followed by B and B followed by C.
Programming tools and techniques
B. Selection structure
Selection structure allows execution on one of the two alternative paths depending on a condition.
It is also called decision structure because it helps in making decision about which set of statements
is to be executed.
The program tests the condition, performs step A if condition is true and performs B if condition
is false.
C. Repetition structure
A sequence of steps which are repeated a number of times is called repetition. For a repeating
process to end, a decision must be made. The decision is usually called a test. The position of this
test divides repetition structures into two types : Pre-test and Post-test repetitions.
Pre-test repetitions (sometimes called guarded loops) will perform the test before any part of the
loop occurs.
Post-test repetitions (sometimes called un-guarded loops) will perform the test after the main part
of the loop (the body) has been performed at least once.
Programming tools and techniques
Pseudocode
Pseudocode is an informal language used to express the flow of program. It is made up of two
words: pseudo (false) and code (instruction). It is intended to clarify the structure of an
algorithm. It uses a combination of English words, mathematical notations and a set of
capitalized keywords.
For example:
START
NUMBER len, area,perimeter
INPUT len area =
len*len perimeter
= len*4
OUTPUT area
OUTPUT perimeter
END