190R6 Programming & Pseudocode

Pseudo-code is very helpful in designing the logic used in programming. We use pseudo-code to work out the logic within algorithms (programs) before we write the code, or even before we have chosen the programming language! You need nothing more than paper and a pencil to write meaningful pseudo-code

EXERCISEEXTRA EX

Make pseudo-code to explain these algorithms

  1. Instructions for making a cup of tea using a teabag
    1. option of strong or weak tea
    2. option of with or without milk
  2. Instructions for making milky coffee, with options:
    1. coffee granules
    2. ground coffee in a cafetiere
    3. coffee beans in a coffee percolator
  3. In slide 10, you add 3 test scores
    1. suggest a better way of coding getting the test scores

Write pseudo-code that achieves the following (include comments to explain what is happening)

  1. that reads two numbers and multiplies them together and print out their product.
  2. that tells a user that the number they entered is not a 5 or a 6.
  3. that asks a user to enter a number.
    1. If the number is between 0 and 10, write the word blue
    2. If the number is between 10 and 20, write the word red
    3. If the number is between 20 and 30, write the word green
    4. If it is any other number, write that it is not a correct color option.
  4. to print all multiples of 5 between 1 and 100 (including both 1 and 100).
  5. counts all the even numbers up to a user defined stopping point.
  6. that will process 5 numbers:
    1. Read in 5 separate numbers
    2. Calculate the average of the five numbers
    3. Find the smallest (minimum) and largest (maximum) of the five entered numbers.
    4. Write out the results found from steps 2 and 3 with a message describing what they are
  7. that reads in three numbers and writes them all in sorted order (ascending or descending)
  8. that will calculate a running sum. A user will enter numbers that will be added to the sum.
    When a negative number is encountered, stop adding numbers and write out the final result.