lesson 2 algorithm and flowcharts

16
START Jack up the Car Unscrew the lugs Remove the wheel Spare Tire? Put on Spare Screw the lugs Jack the Car down Go to Vulcanizing shop A A END Y N Usual process of changing a flat tire 1.Jack up the Car 2.Unscrew the lugs 3.Remove the wheel 4.Any Spare tires? 5.If none go to vulcanizing shop 6. If there is Put on the Spare 7.Screw on the lugs 8.Jack the car down

Upload: christopher-olaya

Post on 28-Jul-2015

222 views

Category:

Education


8 download

TRANSCRIPT

Page 1: Lesson 2   algorithm and flowcharts

START

Jack up the Car

Unscrew the lugs

Remove the wheel

Spare Tire?

Put on Spare

Screw the lugs

Jack the Car down

Go to Vulcanizing

shop

A

A

END

YN

Usual process of changing a flat tire1.Jack up the Car2.Unscrew the lugs3.Remove the wheel4.Any Spare tires?5.If none go to vulcanizing shop6. If there is Put on the Spare7.Screw on the lugs8.Jack the car down

Page 2: Lesson 2   algorithm and flowcharts

Algorithm

A list of instructions for carrying out some process step by step.

Algorithms can combine millions of elementary steps, such as additions and subtractions, into a complicated mathematical calculations.

Example of an Algorithm:1.A recipe in a cookbook2.A dance choreography

Page 3: Lesson 2   algorithm and flowcharts

Sample AlgorithmUsual process of changing a flat tire:1.Jack up the Car2.Unscrew the lugs3.Remove the wheel4.Any Spare tires?5.If none, go to vulcanizing shop, If there is Put on the Spare6.Screw on the lugs7.Jack the car down

Page 4: Lesson 2   algorithm and flowcharts

Sample Activity

1. Create an Algorithm for the following:

a. Turning on the computer. b. Enrollment procedure to a school.

Page 5: Lesson 2   algorithm and flowcharts

Assignment Activity1. Create an Algorithm for

cooking Sinigang na Baboy.

Page 6: Lesson 2   algorithm and flowcharts
Page 7: Lesson 2   algorithm and flowcharts

Flowcharts

Is a diagram representing the logical sequence in which a combination of steps or operations is to be performed.

Major Uses: For Documentation- aids in

communicating the nature of the operation.

For Program Development – that is organizing facts, outline problems and deals with it systematically, build step by step reference documentation and reminders.

Page 8: Lesson 2   algorithm and flowcharts

Advantage of Flowchart Learned and applied without formal

knowledge of a programming language.

Provide an alternative to the usual narrative description.

Easier to understand

Page 9: Lesson 2   algorithm and flowcharts

Limitations of Flowchart Do not represent a

programming language. It does not convey why a given

set of operations is made, flowchart only portray how.

Do not highlight important details.

Page 10: Lesson 2   algorithm and flowcharts

Flowchart Symbols Input/Output Symbol –

represents an instruction to an input or an output device.

Processing Symbol – perform processing functions of the program such as arithmetic opera- tions, compare, sort etc.

Denotes a point of the program where more than one path can be taken.

Page 11: Lesson 2   algorithm and flowcharts

Flowchart Symbols Preparation Symbol –

represents instruction that will alter or modify a program’s course of execution.

Terminal Symbol – used to designate the beginning and end of the program.

On-Page connector – nonprocessing symbol used to connect one part of a flowchart.

Page 12: Lesson 2   algorithm and flowcharts

Flowchart Symbols Flow Direction Indicator – used

to show the direction of the processing of data flow.

Flow Lines – used to show reading order or sequence in which symbols are to be read.

Off-page Connector – Designate entry to or exit from a page when a flowchart requires more than one page.

Page 13: Lesson 2   algorithm and flowcharts

Sample FloWcHartSTART

Jack up the Car

Unscrew the lugs

Remove the

wheel

Spare Tire?

Put on Spare

Screw the lugs

Jack the Car down

Go to Vulcanizing

shop

A

A

END

YN

Page 14: Lesson 2   algorithm and flowcharts

Sample Problem The radius of a circle is equal

to one unit. Create an Algorithm and flowchart to compute the corresponding area of the circle and print out the value of the radius and the area.

Page 15: Lesson 2   algorithm and flowcharts

Activity Problem Given three numbers A, B, and

C. Draw a flowchart to compute for the sum, the average, and the product of these value. Print out all the results.

Page 16: Lesson 2   algorithm and flowcharts

Assignment: The PINAHIS Manufacturing Company plans

to give a year-end bonus to each of its employees. Draw a flowchart and an algorithm which will compute the bonus of an employee. Consider the following criteria: If the employee’s monthly salary is less than 1,ooo pesos, the bonus is 50% of the salary; for employees with salaries greater than 1,000 pesos, the bonus is 1,000. Print out the name and corresponding bonus of the employee.