Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

ALGORITHM

ALGORITHM
• a process or set of rules to be followed in calculations or
other problem-solving operations, especially by a
computer.
• An algorithm is a step by step method of solving a
problem. It is commonly used for data processing,
calculation and other related computer and
mathematical operations.
ALGORITHM USING
FLOWCHART AND
PSEUDOCODE
FLOWCHART
• A flowchart is a pictorial representation of an
algorithm in which the steps are drawn in the
form of different shapes of boxes and the logical
flow is indicated by interconnecting arrows.

• The boxes represent operations and the arrows


represent the sequence in which the operations
are implemented.
BENEFITS OF FLOWCHARTS
• Makes Logic Clear
•Communication
•Effective Analysis
• Useful in Coding
• Proper Testing and Debugging
•Appropriate Documentation
FLOWCHART SYMBOLS
• Terminator - This shape depicts the start or stop
point in a process. To designate the start of
flowchart, type words like Start or Begin within this
shape.

Start End
•Data - A Data shape (typically a
Parallelogram) is used to show input or
output from a data source.
•Process - The Process (typically a Rectangle)
shape shows a process, task, action, or
operation.
• Decision - A Decision shape denotes a question or a
branch in the flowchart sequence.
•Flow line - Used to indicate the flow of logic
by connecting symbols.
FORMATIVE
Directions: Create a flowchart for a program that will identify
the highest number between the three numbers. Use three
variables that will represent the three numbers.
1. The program will ask the user to enter 3 numbers.
2. The program will compare which number is the highest between
the three.
3. The program will display the highest number.
• Predefined Process - This shape is used for a
process that has already been defined elsewhere.
• Internal Storage - This shape represents data stored
-- and is used mainly in computer programming
flowcharts. Typically refers to data stored in
memory.
•Document - A Document or a Report is
represented by a rectangle with a curved
bottom-left area. Also represents a printed
document.
•Multidocument - This shape is same as
Document - but with multiple documents or
reports. This can also represent multiple
printed documents.
• Manual Input - This shape depicts manual input --
such as entering data into a computer via a
keyboard.
• Connector - This shape is generally used in complex
flowcharts to connect one point of the chart with
another without having to draw a line.
• Off-Page Connector - This shape is to show that the
flowchart is continued onto another page.
• Summing Junction - This shape is used when multiple input
branches converge into a single process. It’s also used as
the logical AND.
• Or - This shape performs a logical OR on the input
braches. Also, this shape can have multiple output
branches.
EXAMPLES OF THE USE OF
FLOWCHARTS
DRAW A FLOW CHART TO
ADD TWO NUMBERS ENTERED
BY A USER.
DRAW A FLOWCHART TO LOG IN TO FACEBOOK
ACCOUNT
• To log in to facebook account we first enter the facebook URL www.facebook.com
in our browser like Google, Firefox, Safari, Internet Explorer etc. This request is
sent to the facebook server and it responds by sending us the home page of
facebook.
• Next, we enter our registered Email ID and Password and click the Login button.
• Then our login credential is checked. If it is correct, we are show our profile. On
the other hand, if the login credential is wrong then an error occurs and we are
prompted to re-enter our Email ID and Password.
CREATE A FLOW CHART BASED ON THE GIVEN
ALGORITHM
• Algorithm (in simple English)
• Enter www.facebook.com in your browser. (I/O)
• facebook Home page loads (PROCESS)
• Enter your Email ID and Password (I/O)
• Is Email ID and Password Valid (DECISION)
if NO then
Log in error (PROCESS)
go to step 3
else
Display facebook Account (I/O)
Stop
PSEUDO CODE

• Pseudo code is a generic way of describing an algorithm


without using any specific programming language-related
notations.

• It is an outline of a program, written in


a form, which can easily
be converted into real programming statements.
BENEFITS OF PSEUDOCODE
• Pseudocode provides a simple method of developing the program logic
as it uses everyday language to prepare a brief set of instructions in
the order in which they appear in the completed program.
• Language independent
• Easier to develop a program from pseudocode than a flowchart
• Easy to translate pseudocode into a programming language
• Pseudocode is compact and does not tend to run over many pages
• Pseudocode allow programmers who work in different computer
languages

You might also like