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
Make pseudo-code to explain these algorithms
- Instructions for making a cup of tea using a teabag
- option of strong or weak tea
- option of with or without milk
- Instructions for making milky coffee, with options:
- coffee granules
- ground coffee in a cafetiere
- coffee beans in a coffee percolator
- In slide 10, you add 3 test scores
- suggest a better way of coding getting the test scores
Write pseudo-code that achieves the following (include comments to explain what is happening)
- that reads two numbers and multiplies them together and print out their product.
- that tells a user that the number they entered is not a 5 or a 6.
- that asks a user to enter a number.
- If the number is between 0 and 10, write the word blue
- If the number is between 10 and 20, write the word red
- If the number is between 20 and 30, write the word green
- If it is any other number, write that it is not a correct color option.
- to print all multiples of 5 between 1 and 100 (including both 1 and 100).
- counts all the even numbers up to a user defined stopping point.
- that will process 5 numbers:
- Read in 5 separate numbers
- Calculate the average of the five numbers
- Find the smallest (minimum) and largest (maximum) of the five entered numbers.
- Write out the results found from steps 2 and 3 with a message describing what they are
- that reads in three numbers and writes them all in sorted order (ascending or descending)
- 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.