0% found this document useful (0 votes)
184 views20 pages

Introduction To Algorithm & Flowchart - L1

The document introduces algorithms, flowcharts, and pseudocode. It defines an algorithm as a set of instructions to solve a problem, a flowchart as a graphical representation of decisions and results mapped in shapes, and pseudocode as an informal description of a program or algorithm's operating principle. It provides examples of basic flowchart symbols and control structures like sequence, selection, and repetition. Sample problems are given to demonstrate drawing flowcharts and writing algorithms.

Uploaded by

April Vasquez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
184 views20 pages

Introduction To Algorithm & Flowchart - L1

The document introduces algorithms, flowcharts, and pseudocode. It defines an algorithm as a set of instructions to solve a problem, a flowchart as a graphical representation of decisions and results mapped in shapes, and pseudocode as an informal description of a program or algorithm's operating principle. It provides examples of basic flowchart symbols and control structures like sequence, selection, and repetition. Sample problems are given to demonstrate drawing flowcharts and writing algorithms.

Uploaded by

April Vasquez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

INTRODUCTION TO ALGORITHM &

FLOWCHART

DICT22- COMPUTER PROGRAMMING 1


ALGORITHM
Algorithm is a finite set of instructions
that specify the sequence of operations to
be carried out in order to solve a specific
problem or class of problems.
FLOWCHART
A flowchart is a graphical
representation of decisions and
their results mapped out in
individual shapes.
Pseudocode
is an informal high-level description of the
operating principle of a computer program
or other algorithm.
is an artificial and informal language that
helps programmers develop algorithms.
Pseudocode is a "text-based" detail
(algorithmic) design tool.
Sample Flowchart:
Basic Flowcharting Symbols

USED TO SIGNIFY THE


TERMINAL BEGINNING AND END OF THE
FLOWCHART

PREPARATION/
-SIGNIFIES THE PREPARATION
INITIALIZATION OF DATA
-USED TO SELECT INITIAL
CONDITIONS

INPUT/ SHOWS INPUT AND OUTPUT


OUTPUT
Basic Flowcharting Symbols

PERFROMS ANY
PROCESS CALCULATIONS THAT ARE TO
BE DONE

SIGNIFIES ANY DECISIONS THAT


DECISION ARE TO BE DONE

SHOWS THE ENTRY OR EXIT


POINT OF THE FLOWCHART
ON-PAGE
CONNECTOR
Basic Flowcharting Symbols

PERFROMS ANY
CALCULATIONS THAT ARE TO
BE DONE
OFF-PAGE
CONNECTOR

SIGNIFIES THE PROCESS THAT


IS TO BE EXECUTED NEXT

FLOWLINES
Basic Control Structures
SEQUENCE- process is executed from one to another in a
straightforward manner.
Example:
Design a flowchart that will accept and display a number.
Write its equivalent algorithm.

START

ALGORITHM:
READ N 1. READ IN THE VALUE OF N.
2. PRINT THE VALUE OF N.
PRINT N

END
Example:
Draw a flowchart that will compute and display the sum
and product of two numbers. Write its equivalent
algorithm.
ALGORITHM:
1. INITIALIZE SUM AND PRODUCT INTO 0.
START 2. READ IN THE VALUES OF A AND B.
3. COMPUTE SUM BY ADDING A AND B THEN
SUM=0 COMPUTE PRODUCT BY MUTIPLYING A AND B.
PRODUCT=0 4. PRINT THE COMPUTED VALUE OF SUM AND
PRODUCT.
READ A, B

SUM=A+B PRINT SUM,


PRODUCT=A*B
END
PRODUCT
Basic Control Structures
SELECTION (If-then-else)- a choice is provided
between two alternatives.

A
T

F
B
Example:

Draw a flowchart that will input a grade of


student and determine whether the grade is
passed or failed. Print the name, grade and
remarks of student. Write its equivalent
algorithm.
Example:
START ALGORITHM:
STEP 1: INITIALIZE Name AND Remarks INTO BLANKS
Name=“ “ STEP2: READ IN VALUES FOR Name AND Grade.
Remarks=“ “ STEP3: TEST IF Grade IS GREATER THAN OR EQUAL TO
60.
READ STEP 4: IF Grade IS GREATER THAN OR EQUAL TO 60,
Name, Remark IS “Passed”. HOWEVER , IF Grade IS BELOW
Grade 60, Remark IS “Failed”.
STEP 5: PRINT THE Name, Grade AND Remarks
Grade≥ T
Remarks=“Passed”
60

F
PRINT Name,
Remarks=“Failed” Grade, END
Remarks
Basic Control Structures
Repetition (Looping)
Do-while-this structure provides for the repetitive execution of
an operation or routine while the condition is true. As long as
the condition is true, the process is executed.

C F

T
Example:
START ALGORITHM
STEP 1: INITIALIZE THE VALUE
OF C TO 0
C=0
STEP 2: TEST IF C IS LESS THAN
10
F STEP 3: IF C IS LESS THAN 10,
C<10 END
ADD 1 TO THE VALUE OF C,
T PRINT THE VALUE THEN GO
BACK TO STEP 2. HOWEVER, IF
C=C+1
C IS GREATER THAN 10, STOP
PROCESSING.
PRINT C
Exercise:
1. Construct a flowchart that will convert an inputted
number in Fahrenheit to its equivalent measure in
Celsius. Formula: C=(5/9) x (F-32)
2. Draw a flowchart that will input values for A and B.
Compare two values inputted and print which of the
values is higher including the remark “Higher”.
Write its equivalent algorithm.
3. Create a flowchart that will accept 10 and 20 as
input and print the sum of the two numbers
Solution for problem #1
START
ALGORITHM:
C=0 1. Initialize C = 0 and F = 0
F=0
2. Read F
ENTER F 3. Compute Celsius(C) using
C=(5/9)x(F-32)
Compute Celsius
C=(5/9)x(F-32) 4. Display Celsius(C)

Display
Celsius(C)

END
Solution for problem #2
START
ALGORITHM:
A=0, B=0, Read A
1. Initialize A=0, B=0 and
Remarks and B Remarks
2. Read A and B
Display
A
Is 3. Compare values of A and
A>
“A is Yes B? B.
Higher”
No
4. If A is higher than B then
display A with a "Higher"
Display B remark, else display B
“B is Higher”
with a "Higher" remarks.

END
Solution for problem #3
START
ALGORITHM:
Sum=0 1. Initialize sum = 0
2. Enter the numbers (10
Enter 10, 20 and 20)
3. Add them and store the
Sum = 10 + 20
result in sum
4. Print sum
Print sum

END

You might also like