PRB - Order of Events or Sequencing of Instructions (Lesson)

Order of Events or Sequencing of Instructions

Introduction

The order of events or sequencing of instructions allows the computer to do them in the correct order to achieve the result that you want. Order matters. Computers do not know how to use statements, instructions, unless the programmer provides the steps.  

Using PEMDAS (Order of Operations)

In the problems below, the order of operations, PEMDAS (parenthesis, exponents, multiplication and division, addition and subtraction), is a rule that involves maintaining the order and using a left to right process after parenthesis and exponents are evaluated. This is all structured in steps, instructions that a person follows to accomplish the task.   These structured steps, or statements, can be coded by a programmer for a computer to follow as well. However, parts that we take for granted in accomplishing the task must be accounted for.

Using the logic of math operations, what is the difference between 3 * (5+2) and 3* 5 + 2?

Order of Events Solution

Note that the order of operations made a difference in the outcome of the equations. We learned that parenthesis help change the order of operations. What about if there are no parenthesis? 

Test Yourself!

Try these problems and then check your answers.

Sample Problem 1

y = 5 + 2 * 6 - 4 / 2

Sample Problem 2

y = 3 - 8 / 4 * 2 + 7 

Click here to check your answers! Links to an external site.

Thus, we learn that order is important in math. It is also important in most things that we do, even Computer Science.  In order to open a document on the computer if the computer is not up and running, you must first login, locate the file the document is in and then ask by clicking the file name to let the computer know to open the file. There was an order to be followed.  Options for exactly how to locate the document may be available in several different ways once the computer is up and running, but these basic instructions begin the order. Options are choices and we will talk about them later.  

Of course there is plenty of detail at this top level of order that we do not know at this time, including the question: how does the click on the file name tell the computer to open the file?  Everyone does not need to know how this happens. But remember, a computer only does what the programmer tells it to do, so this abstraction has to be coded by a programmer. Thus there are different types of programmers, those that interact with the user, the person typing on the computer, and those that interact by using code to help internal functions.  

IMAGES CREATED BY GAVS AND USED ACCORDING TO TERMS OF USE.