[go: up one dir, main page]

0% found this document useful (0 votes)
9 views17 pages

LOGIC FORMULATION Notes

Uploaded by

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

LOGIC FORMULATION Notes

Uploaded by

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

LOGIC FORMULATION

Programming Cycle

Algorithm
❑ Programming Cycle
Pseudocodes
❑ Algorithm
Flowchart
❑ Pseudocodes
Conditional Statements
❑ Flowchart
Looping Constructs
❑ Conditional Statements
❑ Looping Constructs
Programming Cycle
• Problem Definition

• Problem Analysis
• Input
• Output

• Algorithm Development
• Process
• Pseudocodes and Flowcharts

• Coding and Debugging


Algorithm
• a step-by-step problem-solving procedure, especially an established,
recursive computational procedure for solving a problem in a finite number
of steps
• finite sequence of steps for solving a logical or mathematical problem
• 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

Examples:

1)Baking of chocolate cake


2)Computing for average grade
3)Going from one location to another
Algorithm
• These characteristics will serve as a guide or determiner to have good
algorithms.

1. Specify each step or instruction exactly.


There must be no ambiguity.
The instructions must be clear.

2. There must be a finite number of steps.


The algorithm must terminate.
There must be a stopping point.

3. There must be an output.


The algorithm must produce the correct result.
Pseudocodes
• generic way of describing an algorithm without use of any specific
programming language syntax

• it cannot be executed on a real computer, but it models and resembles real


programming code, and is written at roughly the same level of detail

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
Flowchart
• 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

• symbols such as squares, diamonds, and ovals represent various operations

• these symbols are connected by lines and arrows to indicate the flow of data
or control from one point to another
Flowchart
• Flowchart Symbols

Decision block
Terminal block
Initialization block
Process block

Connector
Input/Output block

Flow Lines
Flowchart
Flow Lines
• 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
• used to connect blocks by exiting from one and entering another
Flowchart
Terminal block
• ovals or rounded rectangles are used to indicate the start and the 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 lines entering it and only one exiting it; an end or exit has
one flow line entering it but none exiting it

START

END
Flowchart
Initialization block
• used for declaring / initializing variables needed to solve a certain process
• Declaration
• binding of an identifier to the information that relates to it
• stating a variable name to be used
• Initialization
• to set (a starting value of a variable)
• to prepare (a computer or a printer) for use; boot
• to format (a storage medium, such as a disk)
X = 10
Y = 25
Flowchart
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

X=Y+Z
A = 18
B=A-2
Flowchart
Input/Output block
• the parallelogram indicates input to and output operations
• an I/O block has one entrance and only one exit

Get X Display X
Flowchart
Decision block
• the diamond indicates a decision
• it has one entrance and exactly two exits from the block
• one exit is the action when the resultant is TRUE and the other exit is the
action when resultant is FALSE

T F
Condition

Action when Action when


TRUE FALSE
Flowchart
Connectors
• the circle is used as a connection point between two sections of a flowchart
that are not adjacent or closely located to each other
Note: 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.

A
Flowchart
Example 1:
• Create a flowchart that displays your age five years from now. The algorithm
should have a variable that is initialized to your current age.

Start

Age = 18

Age = Age + 5 Display Age Stop


Flowchart
Example 2:
• Create a flowchart that will increase the value of the number by 5 if it is
greater than 10 and display the result; otherwise do nothing.

Start Yes No
x > 10?

x=0 x=x+5

Get x Display x

Stop
Flowchart
Example 3:
• Create a flowchart that displays the user’s name, birthday, age, sex, and
phone number. Your flowchart should display the variables with the
following format:
Name: ??????
Age: ?? Start
BDay: ?????????
Sex: ? Name=“”
BDay=“”
Phone#: ??????? Age=0
Sex=‘ ’
Pno=“|”

Display “Name:” Name


“Age:” Age
Get Name, BDay, “BDay:” BDay Stop
Age, Sex, Pno “Sex:” Sex
“Phone#:” Pno

You might also like