Unit 2
Unit 2
In order to instruct a computer correctly, the user must have clear understanding of
the problem to be solved. A part from this he should be able to develop a method,
in the form of series of sequential steps, to solve it. Once the problem is well-
defined and a method of solving it is developed, then instructing the computer to
solve the problem becomes relatively easier task.
A computer cannot solve a problem on its own. One has to provide step by step
solutions of the problem to the computer.
In fact, the task of problem solving is not that of the computer. It is the
programmer who has to write down the solution to the problem in terms of simple
operations which the computer can understand and execute.
In order to solve a problem by the computer, one has to pass though certain stages
or steps. They are
1. Problem Analysis
2. Algorithm Development
3. Flowcharting
4. Coding
5. Compilation and Execution
7. Documentation
1. Problem Analysis
2. Algorithm Development
Advantages of algorithm
5. By using algorithm, the problem is broken down into smaller pieces or steps
hence, it is easier for programmer to convert it into an actual program
Disadvantages of algorithm.
Step 1: Start
Step 4: Add num1 and num2 and assign the result to sum.
Sum=num1+num2
Step 6: Stop
Step 1: Start
Step 5: Stop.
Step 1: Start
Step 2: Initialize X as 1,
Step 3: Print X
Step 4: Increment X by 1
go back to step 3
Else
Go to step 6
Step 6: Stop
Q. Write an algorithm and draw a flow chart to find whether a number even
or odd
3. Flowcharting
Advantages of Flowcharts
• Communication
• Effective Analysis
• Proper Documentation
• Efficient Coding
Disadvantages of flowchart
3. Difficult to alter the flowchart. Sometimes, the designer needs to redraw the
complete flowchart to change the logic of the flowchart or to alter the
flowchart.
4. Since it uses special sets of symbols for every action, it is quite a tedious
task to develop a flowchart as it requires special tools to draw the necessary
symbols.
Flowchart Symbols
The symbols that we make use while drawing flowcharts as given below are as per
conventions followed by International Standard Organization (ISO).
b. Input and output indicators: Parallelograms are used to represent input and
output operations. Statements like INPUT, READ and PRINT are represented in
these Parallelograms.
e. Flow Lines: Flow lines indicate the direction being followed in the flowchart. In
a Flowchart, every line must have an arrow on it to indicate the direction. The
arrows may be in any direction
f. On- Page connectors: Circles are used to join the different parts of a flowchart
and these circles are called on-page connectors. The uses of these connectors give
a neat shape to the flowcharts. Ina complicated problems, a flowchart may run in to
several pages. The parts of the flowchart on different pages are to be joined with
each other. The parts to be joined are indicated by the circle.
Points to remember
4. Coding
• The process of transforming the program logic design into computer language
format.
• An act of transforming operations in each box of the flowchart in terms of the
statement of the program.
• The code written using programming language is also known as source code.
• Coding isn’t the only task to be done to solve a problem using computer.
5. Compilation and Execution
• Process of changing high level language into machine level language.
• It is done by special software, COMPILER
• The compilation process tests the program whether it contains syntax errors or
not.
• If syntax errors are present, compiler cannot compile the code.
• Once the compilation is completed then the program is linked with other object
programs needed for execution, there by resulting in a binary program and then the
program is loaded in the memory for the purpose of execution and finally it is
executed.
• The program may ask user for inputs and generates outputs after processing the
inputs.
7. Program Documentation
• Helps to those who use, maintain and extend the program in future.
• A program may be difficult to understand even to programmer who wrote the
code after some
days.
• Properly documented program is necessary which will be useful and efficient in
debugging,
testing, maintenance and redesign process.