Want to create interactive content? It’s easy in Genially!

Reuse this genially

PROGRAM DESIGN TECHNIQUES- ALGORITHM

kai casabar

Created on March 4, 2022

Start designing with a free template

Discover more than 1500 professional designs like these:

Transcript

PROGRAM DESIGN TECHNIQUES

LESSONs 5 & 6

OBJECTIVE

UNDERSTAND THE FUNCTION, PURPOSE AND TERM ALGOROTHM

WRITE ALGORITHM

CONVERT ALOGORITHM TO PSEUDOCODES

LEARN TO DRAW FLOW CHARTS AND HOW TO CONVERT ALGORITHM TO FLOWCHART

PROGRAM DESIGN

a.k.a SOFTWARE DESIGN, this is the process of developin how a computer program should work- put simply .it is designing on how a specific program should respond to a set of interrelated inputs. it also talks about on how to write a workflow that will illustrates the sequence of options, actions and output.(flowchart)

ALGORITHM

DEFINITION, FUNCTION AND CHARACTERISTICS

ALGORITHM

  • THE STEP BY STEP PROCEDURE TO SOLVE A GIVEN PROBLEM

EXAMPLE

STEP 1: STARTSTEP 2: Declare variable num 1, num 2, and sum STEP 3: Read values num 1, and num 2 STEP 4: Add num1 and num2 and assign the result to sum using the formula (sum=num1 + num2) STEP 5: Display sum STEP 6: STOP

ORGANIZED AND IT FOLLOWS A LOGICAL ORDER

CHARACTERISTICS OF ALGORITHM

IT HAVE A CLEAR INSTRUCTIONS

REALISTIC OR DOABLE INSTRUCTIONS

IT SOLVE A PROBLEM OR PROCUDE A RESULTS

CHARACTERISTICS OF ALGORITHM

ALWAYS END IN A GIVEN AMOUNT OF TIME

METHODS OF WRITING ALGORITHM

1. STEPPING

This is a method where all instructions follow each other in a particular order to solve the problem- ordered in a set of steps

Problem: To compute the sum of three numbersAlgorithm: 1. Add the three numbers together2. write down the answer

2. LOOPING

Consits of instructions that are repeated a number of times to get a resolution

Different TYPES of LOOPS

Loop that carries out instructions repeatedly, and stops when given the UNTIL command.

a. REPEAT UNTIL

Problem: To wash the glass windowpaneAlgorithm: 1. REPEAT2. Wash with warm soapy water 3. UNTIL the window is clear

2. LOOPING

Consits of instructions that are repeated a number of times to get a resolution

Different TYPES of LOOPS

b. WHILE

Loop where instructions are carried out while the condition is true; otherwise, the loop stops indicated by the END WHILE statement

Problem: To ask for a number less than 5, then stop when such number is givenAlgorithm: 1. WHILE number given is less than 52. ask for the number less than 53. END WHILE

2. LOOPING

Consits of instructions that are repeated a number of times to get a resolution

Different TYPES of LOOPS

Loop that keeps on carrying out a command or commands, for given number of times.here, the number of times the instructions are repeated must be declared. the repeated instructions are place in between the FOR and END for commands.

c. FOR

Problem: To print the numbers from 1 to 10Algorithm: 1. FOR n= 1 to 102. Print n 3. END FOR

3. CHOOSING or SELECTION

This method is used if the problem requires decision making . We use IF - THEN command for this conditional statement. the IF command is followed by an action or instruction to be executed . if the condition is satisfied we follow it with the THEN command

Problem: To decide to go home Algorithm: 1. IF the time is 5pm or later than 5 pm2. THEN go home

2 WAYS IN PRESENTING ALGORITHM

FLOW CHART

PSEUDO CODE

IT ILLUSTRATES THE NATURE AND SEQUENCE OF AEVNTS OF AN OPERATION AND PROCEDURE

ARE SHORT PHRASES THAT DESCRIBE THE INSTRUCTIONS OF AN ALGORITHM

AND

THIS IS A GRAPHICAL REPRESENTATION THAT USES SYMBOLS TO REPRESENT THE ALGORITHM

THIS IS A COMPACT AND INFORMAL HIGH LEVEL DESCRIPTION OF A PROGRAM

PSEUDO CODE

DEFINITION, FUNCTION AND STRUCTURE

PSEUDO CODE

THIS IS A COMPACT AND INFORMAL HIGH LEVEL DESCRIPTION OF A PROGRAM

+ Info

KEY WORDS IN PSEUDO CODES

INPUT: READ, OBTAIN, GETOUTPUT: PRINT, DISPLAY, SHOW

PROCESS:Compute: COMPUTE/ CALCULATE/ DETERMINEInitialize: SET/ INITAdd One: INCREMENT

EXAMPLE

Pseudo code to add to numbers entered by the user

BeginInitialize num 1, num2, sum Read num1 , num 2. Compute sum as sum=num1 + num2 Write sum End

3 LOGIC STRUCTURES OF PSEUDO CODE

ITERATION

SELECTION

SEQUENCE

THE SIMPLIEST FORM OF PROGRAM DESIGN

CONTROL STRUCTURE IS INDICATED BY USING, IF - THEN - ELSE STATEMENT.

A.K.A LOOP STRUCTURE PERFORMS THE ACTION REPEATEDLY WHILE THE CONDITION RETURNS TRUE

A CONTROL STRUCTURE THAT PERFORMS THE ACTIONS FROM TOP - BOTTOM

+Info

+Info

+Info

FLOW CHART

DEFINITION, FUNCTION, SYMBOL AND STRUCTURE

FLOW CHART

THIS IS A GRAPHICAL REPRESENTATION THAT USES SYMBOLS TO REPRESENT THE ALGORITHM

+ Info

FLOWCHART SYMBOLS

TERMINAL

Used to signify the Beginning and End of the flowchart.

PREPARATION / INITIALIZATION

Signifies the preparation of Data. used to select initial conditions and to represent instruction

FLOWCHART SYMBOLS

INPUT/ OTPUT

Sows the INput and Output. Data are read into a computer memory from an input device or data are passed from the memory to an output device.

PROCESS BOX

Performs any operation or calculations that are to be done.

FLOWCHART SYMBOLS

DECISION BOX

Signified the decision. Two alternative execution paths are possible. ("YES" or "NO" )

ON- PAGE CONNECTOR

Shows the entry or exit point of the flowchart. this is a non-processing symbol used to connect one part to another.without drawing flow lines.

FLOWCHART SYMBOLS

OFF- PAGE CONNECTOR

Designates ENTRY or EXIT from one page to another

FLOWLINES

Signify the process that is to be executed next. They show the direction of the flowchart/

OPERATIONS USED IN FLOWCHARTING

OPERATIONS USED IN FLOWCHARTING

BASIC LOGIC STRUCTURES IN FLOWCHART

ITERATION

SELECTION

SEQUENTIAL

Perform statements in the order they are written

Perform statements base on condition

Perform satements REpeatedly

+Info

+Info

+Info

BASIC LOGIC STRUCTURES IN FLOWCHART

START

SEQUENTIAL FLOWCHART

Read num 1, num 2
Flowchart add two numbers entered by the user
sum=num1 + num2
Print sum
END
START

SELECTION FLOWCHART

Read num 1, num 2
Yes
No
Flowchart to determine if the number is Positive or Negative integer.
if num > 0
Print "POSITIVE"
Print "NEGATIVE"
END

ITERATIONFLOWCHART

START
Flowchart to determine if the number is Positive or Negative integer.
Read num 1, num 2
No
If num >0
Print"Negative"
Yes
Print "POsitive"
END

ITERATIONFLOWCHART

START
Flowchart to determine if the number is Positive or Negative integer.
Read num
No
If num >0
Yes

ITERATIONFLOWCHART

Flowchart to determine if the number is Positive or Negative integer.
Print "Negative"
Print "POsitive"
END

Thanks!