03-Principle of Programming
03-Principle of Programming
r1 rivat
_
Fil Cha e Su
e1
. ng b
Di path e()
r1
En .pa =
Dr d S th
Chapter 3
ive Priv ub
1_ ate
Di Cha Su
Dr r1.p nge b
i ve a t ( )
1 h
En .Driv =
Principles of
dS e
ub
Pr
iv
Fil Form ate
e1
.Pa _Lo Sub
tte ad(
"*. rn =
En j p
d S g"
)
Programming &
ub
Problem Solving
Prepared By TCA Gafoor, AKM HSS Kottoor,Malappuram
http://www.hsslive.in
Program, Programming,
Programmer, Programming
Language
A computer program is a sequence of
instructions to solve a particular task.
9847995577
Top down design
Any complex problem can be solved by
breaking it down into different task and
solving each task. This concept is known top
down design
Top down–Breaking the overall procedure in to
modules and sub divide them until lowest level
reached.
Bottom up design
Bottom up- Starts from lowest level to the
highest level..
9847995577
Main Program
Sub Program
Sub Program 1 Sub Program 3
2
9847995577
Phases in Programming
Problem
Identification 1. Problem Identification
2. Algorithm & Flow Chart
Algorithm &
Flow Chart 3.Coding
4.Translation
Coding 5.Debugging
6.Execution & Testing
7.Documentation
Translation
Debugging
Execution &
Testing
Documentati
on
9847995577
1: Problem Identification
Real life Example:-
Suppose you are suffering from a stomach pain.
9847995577
2. Algorithms & Flow Chart
Algorithm:-
The Step-by-Step procedure to solve a problem is known as
algorithm.
E.g.:- Algorithm for Finding the Sum and Average
Procedure
Step 1: Input three numbers
Step 2: Add these numbers to get the sum
Step 3: Divide the sum by 3 to get the average
Step 4: Print sum and average
Algorithm
Step 1: Start
Step 2: input A,B,C
Step 3: S=A+B+C
Step 4: Avg=S/3
Step 5: Print S,Avg
Step 6: Stop 9847995577
E.g.:- 2 Write the algorithm for finding the area
and perimeter of a rectangle
o Perimeter=2(Length+Breadth),
o Area=Length X Breadth
Algorithm
Step 1: Start
Step 2: Input L,B
Step 3: P=2*(L+B)
Step 4: A=L*B
Step 5: Print P,A
Step 6: Stop
9847995577
Flowchart
The pictorial or Graphical representation of
an algorithm is known as Flowchart.
Flowchart Symbols
1. Terminal:-
It is used to indicate the beginning (START),
ending (STOP) of the program. It is the 1 st
symbol and last symbol in the flowchart.
9847995577
2. Input/Output:-
The parallelogram is used as the
input/output symbol. It denotes the
input/output device in the program.
3. Process:-
A rectangle is used to represent the
processing step. Arithmetic operations such
addition, subtraction, multiplication,
division are expressed using this symbol.
9847995577
4. Decision:-
Rectangle for
assigning values
and processing
Arrows to
denote
Diamond or Control flow
rhombus for
decision.
9847995577
Advantages of Flowcharts
Better Communication
Effective analysis
Effective synthesis (different modules can be
combined easily)
Efficient Coding
Limitation of Flowcharts
Time consuming Job
Modification requires ,new flowchart
No standard for amount of detail included
9847995577
Terminal
Start
Start/
E.g. Flowchart for Finding
Sum & Average of 3 numbers
Stop
Symbol
Input
A,B,C
Input/
output
Symbol
S=A+B+C
Avg=S/3
Process,
Print Including
S, Avg All
Arithmetic
Operations
Stop
9847995577
E.g. Find the area and perimeter of a rectangle
Start
Algorithm
Input
L,B
Step 1: Start
Step 2: Input L,B
Step 3:
P=2*(L+B) P=2*(L+B)
A=L*B
Step 4: A=L*B
Step 5: Print P,A
Print
P,A Step 6: Stop
Stop
9847995577
E.g. Find the biggest from Two numbers
Start
Input
A,B
Yes No
IF
A>B
Print A Print B
is Big is Big
Stop
9847995577
E.g. Check the given number is odd or Even
Start
No
Yes IF
Reminder*
of N/2 is 0
Print N Print N
is Even is Odd
Stop
9847995577
E.g. Find the biggest from three numbers
Start
Input
A,B,C
Yes No
IF
A>B
No No Yes
Yes
IF IF
A>C B>C
Stop
9847995577
E.g. FLOW CHART TO DISPLAY 1 TO 100
Start
N=1
Print
N1
N=N+1
Ye
IF s
N<=100
No
9847995577 Stop
E.g. FLOW CHART TO DISPLAY 1 TO 100
Start
N=1
Print
N1
N=N+1
Ye
IF s
N<=100
No
9847995577 Stop
E.g. FLOW CHART TO DISPLAY SUM OF FIRST 100 NUMBERS
Start
A=1
SUM=0
No
IF
A<=100
Ye
s
Print
SUM=SUM
SUM
+A
A=A+1 Stop
9847995577
E.g. FLOW CHART TO DISPLAY SUM OF FIRST N NUMBERS
Start
Input
N
A=1
SUM=0
No
IF
A<=N
Ye
s
Print
SUM=SUM
SUM
+A
A=A+1 Stop
9847995577
E.g. FLOW CHART TO DISPLAY MULTIPLES OF A NUMBER
Start
Input
N
A=1
M=A X N
Print
M
A=A+1
Ye
No s
IF
Stop A<=10
9847995577
3. Coding
The process of writing program instruction to
solve a problem is called coding.
The Program written in any HLL in known as
source code.
E.g. COBOL,C++, Pascal ,JAVA,VB etc
9847995577
4. Translation
It is the process of converting a program
written in high level language into machine
language.
The compiler or Interpreter is used for this
purpose.
9847995577
7. Documentation
It is the process of providing sufficient
information in a program to understanding
its working to other programmers.like
system manual,user catalog, user
help(extrenal documentation)
We can also use comments enclosed in
special symbols inside the program code
(internal documentation).it can contains
details about programs/program
codes ,usages of codes etc
9847995577
THE END
Prepared By TCA Gafoor,
AKM HSS Kottoor,Malappuram
http://www.hsslive.in