Skip to content

Latest commit

 

History

History
21 lines (15 loc) · 533 Bytes

File metadata and controls

21 lines (15 loc) · 533 Bytes

Pseudocode: Count Negative Numbers

define procedure count_negative
  input: a pile of numbers, call it PILE

  label a sticky note COUNT_SO_FAR, write 0 on it

  foreach NUMBER in PILE, do the following:
    if NUMBER < 0, then:
      replace value of COUNT_SO_FAR with value of COUNT_SO_FAR plus 1
    end if
  end foreach

  return COUNT_SO_FAR sticky note
end define procedure

let PILE be [1, 15, -10, 3, 15, 88]
call procedure count_negative with inputs: PILE  // will give 1 since there is one negative numbers