Sequences, Selections, Loops

Computer Science Fundamentals — Sequencing, Selection & Iteration

Any Algorithm you ever write will be based off of the three main building blocks mentioned in the title of this article.

4 min readOct 13, 2019

--

Sequencing:

“This means that the computer will run your code in order, one line at a time from the top to the bottom of your program. It will start at line 1, then execute line 2 then line 3 and so on till it reaches the last line of your program.”

An example of sequencing can be seen in figure 1. This code will execute one line after the other. It will skip past lines 1 and 2, assign a variable called x, with the value 24, to memory on line 3. At Line 4 it will alter that variable to a new value of 35. Line 6 will assign a value of 9 to a variable called y. Line 8 will print out the addition of the two variables.

Sequencing is programming in its simplistic form. code is ran line by line until the execution is complete.

Selection:

Sometimes you only want some lines of code to be run only if a condition is met, otherwise you want the computer to ignore these lines and jump over them. This is known as Selection and is achieved by using IF statements.

--

--

George Field

Software Engineer, creative thinker passionate about creating Applications and data solutions. Twitter: @degreelessdev