06 - Pseudocode

 1. Pseudocode is a text based way of setting out an algorithm. Pseudocode is.....
2. Realise Coffee is superior to Tea
3.(Ignore teacups) and Fetch a Coffee mug
4. Boil some water
5. Put a spoon of instant coffee into mug
6. Poor water into mug
7. Stir
8. Add sugar (or sweetner)
9. END

  the answer to everything in the universe

  NOT the same as python code

  a formal computer language

  a type of code that hackers use

 2. Pseudocode can differ, as there are no hard and fast rules, but what is important is that it is…..

  as artistic as possible, ambiguous and suitably vague

  creative, polite and similar, when possible, to one particular language preferrably C++ or Java

  easy to read, consistent, unambiguous and error free

  as similar as possible to python programming code

 3. Pseudocode should also be precise. How could the following pseudocode be improved?
CardNumber ....
   CardNumber=INPUT(“Please enter Card Number”)
      Pin=INPUT(“Please enter Pin”)
      IF Pin != CorrectPin 
         PRINT(“Wrong PIN”)
      END IF
   UNTIL Pin==CorrectPin
   Amount=INPUT(“How much money would you like?”)
   IF Amount <= CurrentBalence THEN
      CurrentBalence = CurrentBalence - Amount
      PRINT(“Sorry, insufficient funds”)

  Delete all the IF statements

  It cannot be improved

  The data types of the inputs could be specified

  Put variables in UPPER CASE

 4. What does the following pseudocode 'do' (or outline)
INPUT length, breadth
area = length * breadth
display area

  None of the above

  Input the dimensions of a rectangle and print the breadth

  Input the dimensions of a rectangle and print its area.

  Input the length and breadth and display length

 5. This pseudocode is an outline for the following:
INPUT a,b,c
if a>b
if c>bigab
    display c
    display bigab

  Input 3 numbers, and print the biggest.

  Input the letters a,b and c and output bigab

  None of the above

  Input the letters a,b and c and output 'endif'

 6. Describe what this pseudocode is outlining?
for n=1 to 10
    input number
display sum

  Input some numbers ("some" has been spelt wrong) and then output them

  Input 10 numbers, and print their total.

  Set sum to 0 and then display sum.

  Input the sum = 0 and add it to number, which gives you the sum

 7. In the following pseudocode, the objective is to display the ages of everyone called "smith". What line of logic is missing from line 4?
open "fred" for input
		read name, age from "fred"
		while not end of file
				display age
			read name, age from "fred"
		close files

  if name is

  for smith = 0 to 10

  while smith = 1

  name = smith

 8. This pseudocode wants to do this: Input 3 numbers and print either an "all 3 equal" or a "not all equal" message. What is missing?
INPUT a,b,c
			display "all 3 equal"
			display "not all equal"

  if (a = b = c)

  if 3 = equal

  if 1,2,3 = equal

  if (a=b) and (a=c)

 9. The following video shows pseudocode for the Binary search. It is acceptable for pseudocode to be the same as python code.



 10. Pseudocode must be:

  Language independent

  in any language except English

  Language dependent

  Language specific