1/20/2020
Flowchart
A flowchart is a diagram that depicts the “flow” of a program.
Pictorial representations of steps/algorithm.
Basic Flowchart Symbols
Terminals
represented by rounded rectangles / Oval
indicate a starting or ending point
START
END
1
1/20/2020
Basic Flowchart Symbols
Input/Output Operations
represented by parallelograms
indicate an input or output operation
Display message
“How many
Read Hours
hours did you
work?”
Basic Flowchart Symbols
Processes
represented by rectangles
indicates a process such as a mathematical
computation or variable assignment
Multiply Hours
by PayRate.
Store result in
GrossPay.
2
1/20/2020
Basic Flowchart Symbols
Line / Arrow
Used to show the flow of data
Basic Flowchart Symbols
Connector
represented by rectangles
Used to connect the part of flowchart /
segments of flowchart A
START
END
A
3
1/20/2020
Basic Flowchart Symbols
Decision Making
Represented by rhombus
Used to make decision / to select one path
according to condition
Flowchart to find sum of two numbers
Start
Read : N1, N2
Sum = N1 + N2
Print : Sum
End
4
1/20/2020
Flowchart to swap two numbers
Start
Read : N1, N2
N3 = N1
N1 = N2
N2 = N3
Print : N1, N2
End
Flowchart to swap two numbers
without Third Variable
Start
Read : N1, N2
N1 = N1 + N2
N2 = N1 – N2
N1 = N1 – N2
Print : N1, N2
End
5
1/20/2020
Flowchart to Find Even or Odd
Start
Read : N1
YES If NO
N1%2
== 0
Print : “EVEN” Print : “ODD”
End
Flowchart to Find Greatest among two
Numbers
Start
Read : N1, N2
YES NO
If
N1>N2
Print : “N1 is Print : “N2 is
Greatest” Greatest”
End
6
1/20/2020
Flowchart to Find Greatest among
three Numbers
Start
Read : N1, N2, N3
YES If If
NO
N1>N2 N2>N1
and and
N1>N3 N2>N3
Print : “N1 is YES Print : “N3 is
Greatest” Print : “N2 is Greatest”
Greatest”
End
Flowchart to Find Greatest among three Numbers
Start
Read : N1, N2, N3
If If NO
N1>N2 N2>N3
NO
YES
YES
If
N1>N3
NO Print : “N2 is Print : “N3 is
Greatest” Greatest”
YES
Print : “N1 is Print : “N3 is
Greatest” Greatest”
End
7
1/20/2020
Algorithm to Print 1 to 10
PRINT_1_TO_10()
This algorithm prints 1 to 10.
Begin
1. Print : 1
2. Print : 2
3. Print : 3
4. Print : 4
.
.
.
10. Print : 10
End
Algorithm to Print 1 to 10
PRINT_1_TO_10()
This algorithm prints 1 to 10.
Begin
1. Set i =1
2. Print : i
3. Set i = i+1
4. Print : i
5. Set i = i+1
.
.
10. Print : i
11. Set i = i+1
End
8
1/20/2020
Algorithm to Print 1 to 10
PRINT_1_TO_10()
This algorithm prints 1 to 10.
Begin
1. Set i = 1
2. Repeat step 3 to 4 until i<=10 do
3. print : i
4. Set i = i+1
End
Flowchart to print 1 to 10
START
Set i = 1
If
i<=10
Print : i
STOP
Set i = i+1
9
1/20/2020
Algorithm to Print the Table of 2
PRINT_TABLE_TWO()
This algorithm prints the table of 2.
Begin
1. Set i = 2
2. Repeat step 3 to 4 until i<=20 do
3. print : i
4. Set i = i+2
End
Algorithm to Print the Table of 2
PRINT_TABLE_TWO()
This algorithm prints the table of 2.
Begin
1. Set i = 1
2. Repeat step 3 to 4 until i<=10 do
3. print : 2*i
4. Set i = i+1
End
10
1/20/2020
Flowchart to print Table of 2
START
Set i = 1
If
i<=10
Print : 2*i
STOP
Set i = i+1
Algorithm to Print the Table of n
PRINT_TABLE_N()
This algorithm prints the table of N.
Begin
1. Take a value from user, say n
2. Set i = 1
3. Repeat step 3 to 4 until i<=10 do
4. print : n*i
5. Set i = i+1
End
11
1/20/2020
Flowchart to print Table of N
START
Read : n
Set i = 1
If
i<=10
Print : n*i
STOP
Set i = i+1
Algorithm to Print Even Numbers
between 1 to 100
PRINT_EVEN_1_TO_100()
This algorithm prints Even numbers between 1 to
100.
Begin
1. Set i = 1
2. Repeat step 3 to 4 until i<=100 do
3. if i%2 == 0 then
print : i
4. Set i = i+1
End
12
1/20/2020
Flowchart to Print Even Numbers
between 1 to 100
START
Set i = 1
NO YES NO
If If
i%2 == 0 i<=100
YES
Print : i STOP
Set i = i+1
Algorithm to find the factorial of a
given Number
FACTORIAL(n)
This algorithm finds the factorial of a given number.
Begin
1. Take a value from user, say n
2. set fact=1 and i=2
3. Repeat step 4 to 5 until i<=n do
4. set fact = fact * i
5. set i = i + 1
6. print : fact
End
13
1/20/2020
Flowchart to find the factorial of a
given Number
START
Read : n
Set i=2 and
fact = 1
If
Print : fact STOP
i<=n
Set fact = fact * I
Set i = i+1
PRIME(n)
This algorithm finds the given number is prime number or not.
Begin
1. Take a value from user, say n
2. set count=0 and i=2
3. Repeat step 4 to 5 until i<=n do
4. if n%i == 0 then
set count = count + 1
5. Set i = i + 1
6. if count == 1 then
print : “Number is Prime”
7. Otherwise
Print: ”Number is not Prime”
End
14
1/20/2020
Flowchart to find whether a given
number is prime or not
START
Read : n NO
If n%i
== 0
Set i=2 and
count = 0
YES
Set count=count+1
Print : YES If YES
If
“PRIME” count
i<=n
==1 NO Set i = i + 1
NO
STOP Print : “NOT
PRIME”
Computer Programming Languages
Machine Language
Instructions are formed by tacking different combinations of 0s
and 1s.
Advantage:
Translation Free
High Speed
Disadvantage:
Machine Dependent
Complex Language
15
1/20/2020
Assembly Language
It uses symbolic notation (Mnemonic) to represent
machine language instructions.
Advantages
Easy to understand
Less error prone
Disadvantages
Machine Dependent
Harder to learn
High Level Language
Program statement are not closely related to the internal
characteristics of the computer.
Programs are machine independent.
Advantage
Machine independent
Readability
Easy Debugging
Disadvantage
Less Efficient
Poor control on hardware
16
1/20/2020
Translators
Convert one language into another language
Program Translator Machine Code
Assembler
Compiler
Interpreter
17