0% found this document useful (0 votes)
13 views23 pages

Flowchart Basics and Algorithm Design

The document provides an overview of programming concepts, focusing on algorithms and flowcharts. It explains flowchart symbols and their meanings, including terminal, process, input/output, decision, and initialization blocks. Additionally, it includes examples of flowcharts for various algorithms and references for further reading.

Uploaded by

Hacchi
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)
13 views23 pages

Flowchart Basics and Algorithm Design

The document provides an overview of programming concepts, focusing on algorithms and flowcharts. It explains flowchart symbols and their meanings, including terminal, process, input/output, decision, and initialization blocks. Additionally, it includes examples of flowcharts for various algorithms and references for further reading.

Uploaded by

Hacchi
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

Previously…

Programming.
Elements of programming.
✔ Syntax
✔ Variables
✔ Functions
✔ Arithmetic/Logic Operations
✔ Loop
Programming tools
Previously…
Programming tools
✔ Algorithm
▪ Characteristics
• Clarity and unambiguous
• Well defined input/output
• Finiteness
• Feasible
• Language independent
Previously…
Programming tools
✔ Algorithm
▪ Characteristics of Algorithm
▪ Advantages / disadvantages
▪ How to design an algorithm.
▪ Qualities of a good algorithm
✔ Pseudocode
✔ Flowchart – next discussion…
Flowchart
Is a graphical representation of an algorithm.
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 Symbols

Terminal block
Decision block

Process block
Initialization block

Input/Output block Connector

Flow Lines
Terminal / Terminator Block
Ovals or rounded rectangles are used to
indicate the start and the end of a module
or program
START
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 END
A start has flow lines entering it and only
one exiting it; an end or exit has one flow
line entering it but none exiting it.
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. Sum=Num1+Num2
Input / Output Block Output
Input
The parallelogram indicates input to and
output operations
An I/O block has one entrance and only one
exit
Display
Get X
X
Decision Block
The diamond indicates a decision.
It has one entrance and exactly two exits from
the block. T Con F
ditio
One exit is the action when the resultant is n
TRUE and the other exit is the action when
resultant is FALSE. Action Action
when when
TRUE FALSE
Initialization Block
used for declaring / initializing variables
needed to solve a certain process.

Num
Declaration 1
❑ stating a variable name to be use Num
2
Num
Initialization 1=5
❑ to set (a starting value of a variable) Num
2=3
On-Page Connectors
The circle is used as a connection point
between two sections of a flowchart that are A
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
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.
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.
Algorithm:
Start
1. Get user’s age
2. Compute age 5yrs from now
age=age + 5 Age

3. Print age.

Get Age Age = Age + 5 Display Stop


Age
Example 2
Create a flowchart that will compute for the Average score of a student based on three
quizzes. The quiz scores are entered by the user. The scores are integers and may range from 0
to 100, inclusive. However, the Average may have a value having decimal places.
Algorithm: Start

1. Get scores from the three average=(Q1+Q2+Q3)/3

quizzes (q1, q2, q3)


Q1, Q2, Q3
2. Compute for the average. average-=0 Display
Ave
average=(q1 + q2 + q3)/3
3. Print average Get Q1, Q2, Q3 Stop
Example 3
Create a flowchart that ask the user to enter two number. Compute and display their sum.
Algorithm:
1. Enter 1st number (num1). Start

2. Enter 2nd number (num2). sum=num1+num2

3. Compute for the sum of num1 sum=0;


Num1, num2

and num2. Print Sum

sum=num1+num2 Enter num1;


Enter num2; Stop
4. Print sum
More on Decision Box
It should be noted that what you place inside the diamond box are
conditions that either results to TRUE or FALSE
Note: You don’t place conditions that are in essay form, you must be able
to represent it in a mathematical form.

Is
variable
X< X
20? less than
20?
Conditional Statements
✔ Statements that result to TRUE or FALSE.
T F
✔ More on decision block.

Single Alternative Selection Structure


A decision box may not necessarily have to do something for
both the TRUE path and the FALSE path.
Dual Alternative Selection Structure
Performs two different things when the
condition is TRUE or FALSE
T F
Exercise 3:
1. Draw a flowchart that will ask the user to enter a character indicating the user’s gender. If
the user enters ‘M’ display “You’re a Male”.
2. Draw a flowchart that will ask the user to enter a character indicating the user’s gender. If
the user enters ‘M’ display “You’re a Male”. If not assume that the user is a female thus
display “You’re a Female”.
REFERENCES
Website:
✔ Fungsi Motherboard Processor Memori Dan Harddisk | Computer hardware, Computer hardware store,
Computer Pinterest. [Link]
✔ Unit 4 - Hardware & Ergo - Davids BTA30 Portfolio 2016 [Link].
[Link]
✔ Computer Software Icon #229946 - Free Icons Library. [Link].
[Link]
✔ [Link]
✔ [Link]
✔ [Link]
REFERENCES
Textbooks:
✔ Zak, Diane, Introduction to Programming with C++, C & E Publishing c2011
✔ Bronson, Gary J., C++ for Engineers and Scientists, Course Tech c2010
✔ Lambert, Kenneth, Fundamentals of C++ and data structures, 2009, Cengage
✔ Bronson, Gary J, C++ for engineers and scientists, 2010, Course Technology
✔ Deitel, PJ, C : how to program, 2009, Pearson Education, G,
--- END ---

Common questions

Powered by AI

Finiteness ensures that an algorithm terminates after a finite number of steps, preventing it from entering an infinite loop. Without this property, algorithms could run indefinitely without producing a result, leading to inefficiency and resource exhaustion. This can result in crashes or unresponsive systems, making the algorithm unusable in practical applications .

Language independence in algorithms is an advantage because it allows the underlying logical structure of the algorithm to be used and understood across different programming languages and systems. This facilitates algorithm reusability, sharing, and collaboration among developers who may be using different languages or working on different platforms. It ensures that the algorithm's principles and logic remain consistent and can be implemented as needed without the constraints of specific syntax or language features, thus promoting wider applicability and ease of integration .

Clarity and unambiguity in an algorithm are crucial for successful implementation and maintenance as they ensure that the algorithm is interpreted and executed in the same way by different developers or during future revisions. Clear and unambiguous algorithms reduce the risk of errors during translation into code, facilitate easier debugging, and promote understanding across team members, making enhancements, maintenance, and troubleshooting more efficient and less error-prone .

Dual alternative selection structures allow an algorithm to perform different actions based on a decision, not limited to a binary outcome. These structures enable more complex decision-making by evaluating conditions and executing a specific block of instructions depending on whether the condition is TRUE or FALSE. Such structures increase the flexibility and functionality of an algorithm by allowing it to handle a wider range of scenarios and outcomes efficiently, ensuring that different paths are well-defined and executed appropriately .

On-page connectors are advantageous when a flowchart is large or complex because they help keep the chart readable by reducing the need for long flow lines crisscrossing the diagram. These connectors serve as a 'jump' mechanism to connect non-adjacent parts of the flowchart. However, overusing them can clutter the diagram, making it difficult to follow and understand the sequence of operations, thereby diminishing the clarity that flowcharts are meant to provide .

A well-designed algorithm should be clear and unambiguous, meaning it must be understood easily and interpreted consistently. It needs well-defined inputs and outputs to ensure that data is processed correctly and results are predictable. The algorithm must exhibit finiteness, implying that it concludes after a limited number of steps, and feasibility, suggesting that its operations can be performed within available resources. These characteristics are crucial to ensure that the algorithm is efficient, reliable, and practical in real-world applications .

Pseudocode and flowcharts are both tools for representing algorithms, but they serve different purposes and have different strengths. Pseudocode uses plain language and simple coding-like syntax to describe the steps of an algorithm in a linear format, which can be easy to read and write but may be harder to visualize complex control flow. Flowcharts, on the other hand, provide a graphical representation of the algorithm, making it easier to understand the overall process flow at a glance. However, they can become unwieldy if the algorithm is too complex. Both tools are valuable for designing and communicating algorithms but may be chosen based on the complexity of the task and the audience .

Flowchart symbols provide a visual representation of an algorithm, where each type of symbol denotes a specific operation or step. For example, ovals represent the start and end of a process, rectangles indicate processing steps such as calculations, parallelograms show input/output operations, and diamonds are used for decision points within the algorithm. These standardized symbols allow anyone reading the flowchart to understand the data flow and control logic clearly within a process, facilitating easier communication and analysis of the algorithm .

Initialization blocks in flowcharts are used to declare and set initial values for variables needed in a process. They ensure that all variables have defined starting points before the algorithm begins processing, which helps prevent errors caused by undefined or unexpected values. This ensures the process's correctness and reliability, especially in algorithms that rely on iterative or calculation steps. Proper use of initialization blocks helps maintain data integrity and the algorithm's overall efficiency .

A decision block in a flowchart typically handles two outcomes, as it represents conditions that result in either a TRUE or FALSE outcome, leading to two paths. These paths are represented as separate flow lines exiting the diamond symbol in the chart. To handle multiple outcomes, multiple decision blocks can be chained together, where each decision further specifies an additional condition based on previous outcomes, enabling complex decision-making processes .

You might also like