Lesson 1: an Algorithm, Pseudocode and a Program

Learn python programming in 12 lessons


A computer program is nothing more than a set of instructions that's is used by the computer to performed a task by sequentially following the instructions as stated in the program. When you find yourself with a program that gives undesired results, then you should know that there must be something wrong with the instructions you prepared. To find the error also known as a bug, you have to go through those instructions and find the problematic line. This process is known as debugging and it is a feature available in most IDE easily identified by a symbol of a bug.

When learning to program, you are normally required to brainstorm the set of instructions by writing what is known as an algorithm or pseudo code. An algorithm is a general solution that details the unambiguous steps to be followed by the computer to solve the problem.

If you were to write a program to find the average of three numbers, your algorithm would look something like this:
Total = num1 + num2 + num3
Average = total / 3
Print average
The above algorithm can be used in any computer language to find the average of  three numbers. Notice how syntax was not used in the algorithm, this is because an algorithm is computer language independent and its very high level in such a way that anyone can read and understand. An algorithm can have any if not all of these elements namely a steps, decisions and repetitions.

A pseudo code on the other hand is very high level almost English like but it still is computer language independent. One can refer to an algorithm as an intermediate program that can be converted into any computer language really easily. A pseudo code for finding the average of three numbers can look like this:
Add the three numbers together (total)
Divide the total by three (average)
Display the average on the screen
At this point you should note that there are many ways of solving a problem and this means there should be many different algorithms for the same problem. Our pseudo code above assumes that the three numbers are already known. The algorithm can change to ask a user of the program to enter the three numbers.

In computer science, the first program you would normally learn is called hello world which simply just prints the word "Hello, world!" to the screen. Look at the syntax used to create a simple hello world program and compare it to other languages. 

Share your thoughts