Tom Kelliher, CS17
Feb. 14, 1996
See ``Pseudocoding Conventions,'' pp. 46--47
The process of decomposing (``refining'') a problem (the ``top'') into sub-problems (``down'' a level), each of which may themselves be treated as problems and, therefore, further decomposed (``stepwise'').
read and verify number find and print number's factors print a message if number is prime
read and verify number:
let number = 0 while number < 1 begin print "Enter a positive integer: " read number end end_while
find and print number's factors:
let prime = TRUE let currentFactor = 2 let lastFactor = the square root of number truncated to an integer value while currentFactor <= lastFactor begin if number is evenly divisible by currentFactor begin print currentFactor let number = number / currentFactor end else let currentFactor = currentFactor + 1 end_if end end_while
print a message if number is prime:
if prime == TRUE print "Your number is prime" end_if
determine n determine i read the n numbers into a list arrange the n numbers in the list in descending order pick out the ith number in the list and print it
Work on further refinement in small groups
We won't cover structure charts
Do we need to look at flowcharts?
A computer program:
a sequence of a finite number of statements expressed in a programming language in a specific logical order which, when executed, produces the solution for a problem.
Are these the same?
What types of errors will each uncover?
How would you adequately test
Seemingly trivial, but important