SHS CSS 2 Programming - Week 05
SHS CSS 2 Programming - Week 05
LOGIC FORMULATION
SUMMARY OF LEARNING OUTCOMES (LO):
➢ LO 01: Programming Cycle
➢ LO 02: Algorithm
➢ LO 03: Pseudocode
➢ LO 04: Flowchart
TANAUAN INSTITUTE, INC.
Senior High School Department
Modified Learning Scheme: Workbook
PROGRAMMING LANGUAGES (CSS 2)
1st Semester, S.Y. 2020-2021
Subject Teacher: LORIE A. AVILLANOZA
Values Integration:
Nowadays, PROGRAMMING is already a large part of daily life-from games in gadgets to mainstream movies,
they are anywhere, However, a few decades ago, program is very limited. Programming came a long way before
getting to gadgets, televisions and big screens. Explain problem definition, problem analysis, algorithm, and
coding and debugging.
• Enumerate the guides to a good algorithm
• Define and explain what a pseudocode is
• Enumerate and define the basic flowchart symbols
3. What are some rules that you think must be followed when creating a PSEUDOCODE?
Discussion :
Problem analysis - looking at the problem itself; point of view of the computer; start with
the input/output.
Algorithm development - an outline that breaks problem down into segments; strategy
on how to do the task.
After the problem has been defined, formulate a simple, efficient, and effective approach to solve the
problem. The second step usually involves breaking down the problem into smaller sub-problems.
The third step may be expressed in human language, (English, Tagalog), graphical representation
(flowchart), or pseudocode (a cross between human language and a programming language).
After the algorithm has been constructed, a source code is created. Using the algorithm as a basis, the
source code can be written using the desired programming language.
• A specific set of well-defined, simple mathematical and logical procedures that can be followed to
solve a problem in a finite number of steps.
An algorithm is a finite set of well-defined instructions for accomplishing a task which, given an initial
state, will result in a corresponding recognizable end-state. Algorithms can be implemented by computer
programs, although often in restricted forms; an error in the design of an algorithm leads to failure in
implementing the program.
We use algorithms every day. For example, a recipe for baking a cake is an algorithm. All programs
consist of algorithms may it be simple or complex. Inventing elegant.
algorithms – algorithms that are simple and require the fewest steps possible – are one of the principal
challenges in programming.
Baking a chocolate cake, computing for average grade, or going from one location to another are
examples of everyday life algorithms.
• Specify each step or instruction exactly – There must be no ambiguity or the instructions must be
clear.
• There must be a finite number of steps – The algorithm must terminate and should have a stopping
point.
• There must be an output – The algorithm must produce the correct result.
Various methods and tools are used to represent/describe algorithms and programs.
Examples of which are pseudocodes and flowcharts.
• Generic way of describing an algorithm without the use of any specific programming language
syntax.
While not at end of list compare adjacent elements if elements were switched repeat for entire list.
While not at end of list compare adjacent elements if second is greater than first switch them get next
two elements if elements were switched. repeat for entire list.
Pseudocode consists of short English phrases used to explain a specific task within a program's
algorithm. The rules of Pseudocode are reasonably straight forward. All statements showing
"dependency" are to be indented which include while, do, for, if, and switch.
A pseudocode cannot be compiled nor executed, and there is no real formatting or syntax rules for it. It
is simply an important step in producing the final code. The benefit of a pseudocode is that it enables the
programmer to concentrate on the algorithm without worrying about all the syntactic details of a
particular programming language. In fact, you can write a pseudocode without even knowing what
programming language you will use for the final implementation.
• A chart that contains symbols referring to computer operations, describing how the program
performs.
• A graphic map of the path of control or data through the operations in a program or an information-
handling system.
• These symbols are connected by lines and arrows to indicate the flow of data or control from one
point to another.
Terminal block
Process block
Decision block
Flow Lines
Flow Lines
indicated by directed lines to show the direction of data or the control flow. The arrowhead is sometimes
not shown when the direction of flow is clear. Flow lines are used to connect blocks by exiting from one
and entering another.
• Indicated by straight lines with arrows to show the direction of data flow.
• The arrowhead is sometimes not shown when the direction of flow is clear.
Terminal block
Ovals or rounded rectangles in a flowchart are called Terminal Blocks. These blocks are used to indicate
the start and end of a module or program. An oval is labeled with the name of the module at the start.
The end is indicated by the word end or stop for the top or Control Module. A start has no flow line
entering it and only one exiting it. On the other hand, an end or exit has one flow line entering it but
none exiting it.
START
END
Initialization block
The hexagon, which is called an initialization block, is used for declaring / initializing variables. It has
one entrance and one exit. You can only use variables that had been initialized.
• Declaration:
✓ binding of an identifier to the information that relates to it
✓ stating a variable name to be used
X = 10
• Initialization:
✓ to set (a starting value of a variable) Y = 25
✓ to prepare (a computer or a printer) for use;
✓ to format boot (a storage medium, such as a disk)
Process block
The rectangle indicates a processing block, for such things as calculations, opening and closing files,
and so forth. A processing block has one entrance and one exit.
Get X Display X
One exit is the action when the resultant is TRUE and the other exit is the action when resultant is
FALSE.
• the diamond indicates a decision
• has one entrance and exactly two exits from the block
T F
Condition
Connectors
Circles or Connectors are used for in-page connectors, labeled with uppercase letters while pentagons
are used for off-page connectors, labeled with uppercase letters and a number (typically the page number
of the matching pair). The circle is used as a connection point between two sections of a flowchart that
are not adjacent or closely located to each other. These connectors should be used as little as possible.
They should only be used to enhance readability. Overuse, however, decreases readability and produces
a cluttered effect.
These connectors should be used as little as possible. Overuse, however, decreases readability and
produces a cluttered effect.
• the circle is used as a connection point between two sections of a flowchart that are not adjacent or
closely located to each other.
• used to enhance readability.
Start
Age = 18
Age = Age + 5
Display Age
Stop
• This flowchart shows that the value will increase to 5 if it is greater than 10 and display the result;
otherwise no action shall be done.
Start
FLOWCHART: EXAMPLE 2
Get x
Yes No
x>
10?
x=x+5
Display x
Stop
PROGRAMMING LANGUAGES (CSS 2) / LORIE AVILLANOZA 8
FLOWCHART: EXAMPLE 3
• Create a flowchart that displays the user’s name, birthday, age, gender, and phone number. Your
flowchart should display the variables with the following format:
“Phone#:” Pno
Stop
FLOWCHART: EXAMPLE 4
• Create a flowchart that will compute for the Average score of a student based on three quizzes. The
quiz scores are integers that may range from 0 to 100 and are entered by the user. The Average may
be a decimal number.
Q1: 98 Q2: 79
Q3: 88 Ave is 83.33
Sum=Q1+Q2+Q3
Ave=Sum/3
Display Ave
Stop
Activity :
ACTIVITY 1:
Directions: Draw a flowchart for a college’s admissions office with the following specifications:
• Allow the user to input the student’s high school GPA and admission test score.
• Print the message “Accept” if the student has a grade point average of 3.0 or above and an admission test
score of at least 60.
• If the student does not meet either of the qualification criteria, print “Reject”.
ACTIVITY 2:
Directions: Draw a flowchart for a college’s admissions office with the following specifications:
• Create a flowchart that will increase the value of the number by 5 if it is greater than 10 and display the result.
Otherwise, multiply the value by 5 and display the result.
• Hoffer J., George G., & Valacich J. (2008). In 5 Ed., Modern systems
analysis and design. Pearson Prentice Hall.