Computer Programming: Chapter 2. Problem Solving Using Computer
Computer Programming: Chapter 2. Problem Solving Using Computer
Step 1 : Start
Step 2 : Input numbers „a‟ and „b‟
Step 3 : Sum=a+b
Step 4 : Display “Sum”
Step 5 : Stop
Algorithm to Find the given number is Even or Odd:
Step 1 : Start
Step 2 : Read number „n‟
Step 3 : Rem=number mod 2
Step 4 : if Rem=0 then
print "even number "
else
print "odd number "
endif
Step 5 : End
Flowchart
• Flowchart is a graphical representation of step by step
solution of a given problem. It represents the program
logic in terms of symbols. It is used by the programmers
to develop the program and system designer to represent
the overall system while analyzing and developing the
system.
• A flowchart consists of a set of flowchart symbols
connected by arrows. Each symbol contains information
about what must be done at that point and the arrows
show the flow of execution of the algorithm, i.e. they
show the order in which the instruction must be
executed.
Basic Flowchart Symbols
Ellipse or Oval : Start / Stop
Rectangle : Processing
Diamond : Decision
Circle : Connector
Draw Flowchart:
Debugging
Debugging is the process of detecting, locating
and removing errors in a program. Mistakes may be
syntax error or semantic error or run- time error.
Types of Error
Syntax error
It is the error in the program‟s grammatical rule
in writing format. If a program contains syntax error,
the program will not produce output. This error is
detected by translator during translation so, it is easier
to correct. For e.g. in C language whenever we do not
use semicolon in a simple statement causes syntax
error.
Semantic error
Semantic error is an error in the concept of the
program. It causes a program to operate incorrectly. If
a program contains only a logical error, the program
will be executed and will also produce output but the
output will not be accurate. For e.g. to calculate area
of circle formula is (pi*r*r) but if we write (2*pi*r)
then it will produce semantic error.