




















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
A lecture note from ENG 224, Structured Programming course. It covers the basics of algorithms, flowcharts, and pseudo-codes. how to write algorithms using pseudo-code and find the average of a given set of numbers using flowcharts. It also introduces the systematic approach to defining a problem and explains top-down and bottom-up design approaches.
Typology: Lecture notes
1 / 28
This page cannot be seen from the preview
Don't miss anything!
Find the average of a given set of numbers with flowcharts
How to write Pseudo code
Algorithm Average This algorithm reads a list of numbers and computes their average.
Let: SUM be the total of the numbers read COUNTER be the number of items in the list AVE be the average of all the numbers Set SUM to 0, Set COUNTER to 0. (i.e. initialize variables) While there is data do: Read number COUNTER = COUNTER + 1 (i.e. add 1 to COUNTER, storing result in COUNTER) SUM = SUM + number (i.e. add number to SUM, storing result in SUM) end-while if COUNTER = 0 then AVE = 0 else AVE = SUM/ COUNTER Stop.
A Systematic Approach to Defining a Problem
Divide the problem into three (3) separate components: (a) input or source data provided (b) output or end result required (c)processing - a list of what actions are to be performed
Top-Down Design Approach (Modularization) The modularization approach involves breaking a problem into a set of sub-problems, followed by breaking each sub-problem into a set of tasks, then breaking each task into a set of actions. e.g. Problem 1 Add 23 and 35
-Sub-problem 1: locate bulb (one task, one action) -Sub-problem 2: depress switch
EXAMPLE 4 Given a list of students’ test scores, find the highest and lowest score and the average score.
-Sub-problem 1: read students’ scores -Sub-problem 2: find highest score -Sub-problem 3: find lowest score
Sub-problem 1 can be considered as one action and therefore needs no further refinement. Sub-problems 2 and 3 however can be further divided into a group of actions.
Bottom Up Design Approach (Modularization)