December 13, 2007

We have started the Higher Computing project so all I hear now in lessons is the sound of fingers hitting keys as code is typed up! This is the sound of heaven to computing teachers 🙂

While I don’t have any new “material” to post to the blog I didn’t want to miss the chance to put up some new stuff (all of which I have found from reading other peoples’ blogs).


Students 2.0 is a global group of students blogging about education and the schooling system (with some Scottish content!) which is well worth a read. The quality of their writing is amazing! Do you think you could do something like this?


Compilers and Interpreters

December 5, 2007

I think this is a hard bit of the course to understand (and explain) but here goes:

All high level language (HLL) programs need to be translated into machine code (aka 1’s and 0’s/binary). There are two forms of translators to make this happen; Compilers and Interpreters.

Compilers – These turn the whole HLL program into machine code in one go. This results in a file (object code) that can then be run on any computer system (is very portable) and runs very quickly (as it does not need to be translated again). Unfortunately if you have made a mistake (called a syntax error) in your program then it won’t run at all.

Interpreters – These turn the HLL program into binary each time you try and run it. An interpreter will go through each line of your program each time it translates it. This means that it is slow to translate your program.

Here are the Powerpoints below:


Standard Algorithms 3 & 4

December 3, 2007

So these two find the highest number in a list or the lowest number in a list.  The way they work is this:  look at the first item in the list and make it the maximum, then look at every other item and see if it is more.  Quite simple when you think of it like that.

Here is the pseudocode for finding max:

1.1  set the first item to be the maximum


1.2  for each item (starting with the second)


1.3  if the current item is more than the maximum


1.4  set the current item to be the maximum


1.5  end if


1.6  end loop


1.7 print out the maximum


 Finding the minimum is exactly the same only change more than to read less than (and every maximum to minimum).








Standard Algorithm 2 – Linear Search

November 30, 2007

This algorithm asks the user for something to look for and then checks through a list of items to see if it can find it. If it does find it, the algorithm says in what position it found it. So for example from the following list:

“Stewart”, “Simon”, “Dara”, “Scott”, “Keith”, “Farooq”, “Gaetano”

User Input Algorithm Output

Stewart 1

Dara 3

Gaetano 7

In the same way as the last standard algorithm you need to be able to write the pseudocode in the exam!

1.1 ask for item being searched for


1.2 for each item in the array


1.3 if this item matches the item being searched for

1.4 store the position


1.5 end if


1.6 end loop


1.7 print out where the item was found


Powerpoint below:


Standard Algorithm 1 – Counting Occurrences

November 29, 2007

This is the first standard algorithm (in no particular order) that you have to know, and be able to write a pseudo code version of in the exam.

Put simply this algorithm counts the number of times an item appears in a list. The item could be a name or a number, the list is normally an array.

So for example in the following list:

“A” “B” “B” “C” “B” “A” “A” “B” “C” “B”

The algorithm would ask the user what they are looking for and then should return the results below:

Being looked for                             Number of occurrences

A                                                                          3

B                                                                          5

C                                                                          2

So you need to be able to write the pseudo code that will do this. My answer is below, see the powerpoints at the bottom for more detail:

1.1 ask for item being searched for

1.2 for each item in the array

1.3 if this item matches the item being searched for

1.4 add one to the count

1.5 end if

1.6 end loop

1.7 print out the number of times the item was found




November 26, 2007

I think I have confused at least half the class with my explanation of parameter passing! Or at least maybe not my explanation but certainly my attempted explanation of the NAB type question.

Let me try and simplify it again:

Call by value means a copy of a variable is used in a sub-routine. If it changes the variable, only the copy is changed, not the original.

Call by reference uses the original variable (by referring to the address of the variable rather than a copy). If it changes, then the original is changed also.

If you understand that then you are probably fine! The NAB question was confusing as it lacked some important details.

The other thing we did to day was functions. The important thing about them is that they produce a value. For example random produces a random number.


Here is the powerpoint on parameter passing:



November 23, 2007

This was Mr Polland’s excellent program that I converted in to VB (and am still a bit too excited about).

It has an array of your names, an array of brazilian endings, and it concatenates a random ending onto a substring of your name.

The point of the lesson is to do with Functions. The random function is called with two parameters (low and high) andit then generates a random number between those two. In the program I use that random number to pick a brazilian ending and put it onto your name.

Here is a screenshot:


Local and Global Variables

November 22, 2007

A local variable is declared (set up) and only available for use in the sub-routine it is made in. A global variable is declared at the start of your program (in VB anyway) and can be used anywhere.

It is easier to understand when you look at some code:
private sub get_marks

dim marks(10) as integer

for counter 1 to 10

marks(counter) = inputbox(“Type in your mark”)


end sub

In the code above the array (marks) is only available inside the sub-routine called get_marks. If you try to access it somewhere else, it won’t work i.e. the scope of the variable (array) is local

If you set up the variable (or array) at the start of the program before any sub-routines (like we normally do) then it will be available for use everywhere i.e. the scope of the variable is global

Notes below:


String operations – Sub strings and Concatenation

November 20, 2007

We looked at what a string variable was last week e.g. “James”, “Eh12”. You need to know about two things that you can do to this type of data:

Substring – take a part of a string e.g. take “ame” from “James”

Concatenation – join two strings together e.g. join “Craig” and “mount” to make “Craigmount”

That is pretty much it, except you need to know how to make Visual Basic do this. Here are some examples:

Concatenation is done using the & symbol.

For example:

first = “j”

second = “whiteside”

username = first & second

The code above will make username equal to “jwhiteside“.

Substrings are done by using left, mid (or right).

For example:

day = “wednesday”

firstbit = left(day, 6)

middlebit = mid(day, 4, 3)

lastbit = right(day, 3)

This would make firstbit equal to “Wednes”, secondbit equal to “nes” and lastbit equal to “day”.

Click on the notes below to see the other examples and the questions again.


Sub routines

November 19, 2007

Once I eventually got my program to work in the way it was supposed to 😉 we looked at what a sub-routine is (also called a procedure). There were two sub routines in this program that took in pupil marks and then printed out an average, they are called:

  • fill_array
  • calculate_average

It is good to make use of sub-routines as they increase the maintainability of your program (i.e. other programmers can update your program easily).

These can be called (made to run) from any part of the program.  Click the notes below to see the program:


Because this program makes use of subroutines so it is modular!