To understand the basics of computer programming, you first need to know what is computer programming. Computer programming is defined as creating a sequence of instructions to be carried out by a computer to perform a task.
A computer program is similar to a recipe in cooking. In a recipe, there are ingredients and there are instructions that are done to those ingredients. In programming, there are data and there are instructions (called code) that are done to that data.
For example, here’s a classic egg sandwich recipe:
Ingredients
3 large whole eggs
1 slice Canadian bacon
2 slices whole-wheat bread, toasted
1 tomato, sliced
Instructions
Scramble whole eggs in a bowl
Fry in non-stick skillet with olive oil spray
Dump onto toast
Add bacon and tomato
Serve
And here is a classic piece of computer programming in a made-up computer language to keep it simple:
Data
DataItem A
DataItem B
DataItem C
Instructions
A = 1
B = 2
C = A + B
With the recipe, you first must have your ingredients before you can prepare the meal. In computer programming, you need to tell the computer about your data before it can operate on it.
In the above computer programming example, the computer is first notified of 3 data items or storage areas: A, B and C. The computer is then instructed to insert the value of 1 into the ‘A’ data item (A = 1) and then 2 into the ‘B’ data item (B = 2). The final instruction is for the computer to now add ‘A’ plus ‘B’, which then inserts the value of 3 into the ‘C’ data item.
This is the essence and basics of computer programming.
Now that you understand this, let’s jump right into a simple tutorial in a real programming language called Visual Basic.