Flowcharting and Algorithms
Flowcharting and Algorithms
Algorithms
Flowchart
Use
two-dimensional representation of an
algorithm; the predefined graphic
symbols of a flowchart are used to
indicate the various operations and the
flow of control.
Algorithm
Algorithm
is a finite set of
instructions that specify a
sequence of operations to be
carried out in order to solve a
specific problem or class of
problems.
What it represents
Used to signify the beginning and end
of flowchart
Terminal
Symbols
Input / Output
What it represents
Shows input and output. Data are to
be read into the computer memory
from an input device or data are to be
passed from the memory to an output
device
Performs any calculations that are to
be done
Processing
Signifies any decision that are to be
done
Decision
Symbols
What it represents
Shows the entry or exit point of the
flowchart
Symbols
What it represents
SEQUENCE
process is executed from one to
another in a straightforward
manner.
Algorithm:
EXAMPLE!!
!!
Step 1. Read in the value of N.
Read N
Print N
End
Operators Commonly
Used in Flowcharting
Arithmetic Operators
Operators
Meaning
+
*
/
Addition
Subtraction
Multiplication
Division
Relational Operators
Operators
Meaning
=
>
<
<>
Equal
Greater than
Less than
Not Equal
Logical Operators
Operators
Meaning
&&
||
!
AND
OR
NOT
Sum = 0
Product
=0
Read
A,B
Sum = A+ B
Product =
A*B
Algorithm:
Step 1. Initialize Sum and Product into 0.
Step 2. Read in the values of A and B.
Step 3. Compute Sum by adding A and B
then compute Product by multiplying A
and B.
Step 4. Print the computed value of Sum
and Product.
Print
Sum,
Product
End
Formula :
C=(5/9)x(F32)
Celsius
=0
Read
Fahrenhe
it
Celsius =(5/9)x(F32)
Algorithm:
Print
Celsius
End
F
B
Start
EXAMPLE!!
!!
Step 2. Test if A is greater than B.
Input
A,B
A>B
Print A,
Higher
F
Print B,
Higher
End
Start
Name=
Remarks=
Read
Name,
Grade
Grade
60
Remarks =
Passed
F
Remarks =
Failed
Print
Name,
Grade,
Remarks
End
ANSWER
Algorithm:
Start
Bonus = 0
Read
Name,
Salary
Salary
<
2,000
Bonus = 1,500
T
Bonus =
0.5*Salary
Print
Name,
Bonus
End
Bonus = 0
Bonus = 1,500
Bonus =
0.5*Salary
Read
Name,
Salary
Salary
<
2,000
Print
Name,
Bonus
End
Assignment
Construct a flowchart that will accept the evaluation
score of a faculty and determine its equivalent
remarks. Print the name of the faculty and the
remarks obtained. Remarks (Rem) are based on the
following criteria: Write its equivalent algorithms.
4.50
4.00
3.50
3.00
2.99
5.00
4.49
3.99
3.49
below
Answer
Outstanding
Very Satisfactory
Satisfactory
Needs Improvement
Poor
Quiz
Repetition (Looping)
Do while this structure
provides for the repetitive
execution of an operation or
routine while the condition is
true. The condition is evaluated
before executing any process
statement. As long as the
condition is true, the process is
executed, otherwise, control
flows out of the structure.
C
T
Start
C= 0
C<
10
C=C+1
Print C
End
The initial value of the radius (R) of a circle is equal to 1 unit and each
succeeding radius is 1 unit greater than the value before it. Draw a
flowchart to compute the Area of a circle starting with R = 1 to R = 5,
then print each radius and the corresponding area of a circle.
Start
Algorithm:
Pi =
3.14
R=1
Area = Pi * R *
R
Print R,
Area
R= R + 1
T
R5
End
Assignment
1.
2.
3.
Algorithm:
Step1. Initialize Rem into space or blanks.
Step2. Read in the values of Name and
Score.
Step3. Test the score if it is greater than
or equal to 4.50.
Step4. If the score is greater than or
equal to 4.50, Rem is Outstanding.
However, if the score is less than 4.50,
do step 5.
Step5. Test the score if it is greater than
or equal to 4.00.
Step6. If the score is greater than or
equal to 4.00, Rem is Very
Satisfactory. However, if the score is
less than 4.00, do step 7.
Step7. Test the score if it is greater than
or equal to 3.50.
Step8. If the score is greater than or
equal to 3.50, Rem is Satisfactory.
However, if the score is less than 3.50,
do step 9.
Step9. Test the score if its is greater than
or equal to 3.00.
Step10. If the score is greater than or
equal to 3.00, Rem is Needs
Improvement. However, if the score is
less than 3.00, Rem is Poor.
Step11. Print the name and Rem.
SEQUENCE
1.
2.
3.
4.
SELECTION
1.
2.