LESSON 2
in
Programming Logic Design and
Formulation
Prepared by
Elaine B. Bolambot, MIT
Faculty
At the end of the lesson, the learner
will be able to:
• Identify the different phases in programming
cycle & logic, and properties of Algorithm ;
• Understand the flowchart symbol to illustrate
program flow; and
• Create and implement algorithms using
pseudocode and flowchart
Programming Cycle:
Iterative Steps to
Software Creation
Programming Cycle
The programming cycle, also known as the
software development cycle or the coding
cycle, refers to the iterative process that
programmers follow when creating software
applications. It encompasses the steps involved
in writing, testing, and refining code to achieve
the desired functionality.
Programming Cycle(continuation)
Let's explore the key aspects of the
programming cycle:
Problem Definition and Analysis
Planning
Design
Coding
Testing
Programming Cycle(continuation)
Debugging
Optimization
Documentation
Refining and Iteration
Deployment and Maintenance
Benefits of the Programming Cycle
Structured Development
Quality Assurance
Adaptability
Efficiency
Programming Logic
Programming Logic
Programming logic refers to the systematic
and structured approach that programmers use to
develop algorithms and solve problems using
code.
Key Concepts in Programming Logic
Sequence – it involves arranging instructions in a
specific order to achieve the desired outcome.
Conditional Statements – these are statements
enable the program to make decisions based on
certain conditions.
Loops and Iteration - these are used to execute
a set of instructions repeatedly.
Variables and Data - it involves working with
variables to store and manipulate data.
Key Concepts in Programming
Logic (continuation)
Logical Operators – these are logical operators (AND, OR,
NOT) enable programmers to combine conditions and make
complex decisions based on multiple criteria
Functions and Procedures - it involves organizing code
into functions and procedures, which are blocks of code that
can be reused throughout the program
Error Handling – these are handling errors and exceptions
is essential to ensure that the program gracefully manages
unexpected situations without crashing.
Algorithm Design - involves breaking down complex tasks
into smaller, manageable steps.
Importance of Programming Logic
Accuracy
Efficiency
Debugging
Readability and Maintainability
Example of Programming Logic:
Algorithm
Algorithm
An algorithm is a step-by-step set of
instructions designed to solve a specific problem
or perform a particular task. It's a clear and
unambiguous sequence of actions that, when
followed correctly, leads to the desired outcome.
Algorithms are used in various fields, including
computer science, mathematics, and
engineering, to solve complex problems
efficiently.
Key Characteristics of Algorithms:
Well-Defined
Input and Output
Finiteness
Effectiveness
Deterministic
Example Algorithm
1. Read the first number as fNum.
2. Read the second number as sNum.
3. If fNum is greater than sNum, assign fNum
to max
4. Otherwise, assign sNum to max
5. Print max as the maximum number.
Pseudocode
Pseudocode
Pseudocode is an informal way to express
algorithms using a combination of human-
readable programming language-like
constructs and natural language descriptions.
It provides a high-level description of the
algorithm's logic without getting into the
specifics of actual programming syntax.
Benefits of Pseudocode
Readability
Flexibility
Clarity
Example Pseudocode
Read fNum Read fNum Read fNum
Read sNum Read sNum Read sNum
If fNum > sNum If fNum > sNum If fNum >
max = fNum max = fNum
sNum
Else Print max
max = sNum Print fNum
Else
max = sNum Else
Print max Print max Print sNum
Flowchart
Flowchart
A flowchart is a visual representation of the
sequence of steps and decisions involved in a
process or algorithm. It uses standardized
symbols and arrows to depict the flow of
control in a clear and easily understandable
manner. Flowcharts are widely used to visualize
complex processes, algorithms, and workflows.
Flowchart Symbols
Example Flowchart
Let's consider a simple example of
a flowchart that calculates the
area of a rectangle given its length
and width.
Benefits of Flowchart
Visual Representation
Clarity
Communication
Analysis
Documentation
Flowchart Considerations
Clarity
Simplicity
Consistency
Testing
Thank you!
Examples of Flowchart
1. Draw a flowchart to add two numbers entered by
the user.
2. Draw a flowchart to compute the area of a
circle of Radius R.
3. Draw a flowchart to find the greatest from 2
numbers
Answers of Flowchart
ACTIVITY #1
Directions: Create a flowchart, algorithm and pseudocode of the following below:
1. Draw a flowchart to read the two sides of a rectangle and
calculate its area.
2. Draw a flowchart to read two values, determine the largest
value, and print the largest value with an identifying message.
3. Draw a flowchart that will convert the temperature Fahrenheit
to Celsius( formula to use is : C = 5/9 *( F-32)
4. Draw a flowchart to read a variable num1 = 7 and store the
negative value of num1 in another variable num2.