<< Chapter < Page
  Teaching beginners to code     Page 3 / 9
Chapter >> Page >

Thus, the general requirement for the sequence structure is that one or more actions may be performed in sequence after entry and before exit.

There may not be any branches or loops between the entry and the exit.

All actions must be taken in sequence.

The action elements themselves may be structures

However, it is important to note that one or more of the action elements may themselves be sequence, selection, or loop structures.

If each of the structures that make up the sequence has only one entry point and one exit point, each such structure can be viewed as a single action elementin a sequence of actions.

The sequence structure is the simplest of the three, and there's not much more that I can say about it.

The selection structure

The selection or decision structure can be described as shown in the pseudocode in Image 2 .

Image 2. the selection structure in pseudocode.

Enter Test a condition for true or falseOn true Take one or more actions in sequenceOn false Take none, one, or more actions in sequenceExit
Image 2. The selection structure in pseudocode.

Test a condition for true or false

Once again, there is only one entry point and one exit point.

The first thing that happens following entry is that some condition is tested for true or false .

The concept of something being true or false is commonly referred to as a boolean condition in computer programming (named after George Boole) .

If the condition is true, one or more actions are taken in sequence and control exits the structure.

If the condition is false, none , one or more different actions are taken in sequence and control exits the structure. (Note the inclusion of the word none here.)

The action elements themselves may be structures

Once again, each of the action elements in the sequence may be another sequence, selection, or loop structure.

Eventually all of the actions for a chosen branch will be completed in sequence and control will exit the structure.

Sometimes no action is required on false

It is often the case that no action is required when the test returns false. In that case, control simply exits the structure without performing any actions.

The loop structure

The loop or iteration structure can be described as shown in the pseudocode in Image 3 .

Image 3. the loop structure in pseudocode.

Enter Test a condition for true or falseExit on false On truePerform one or more actions in sequence. Go back and test the condition again
Image 3. The loop structure in pseudocode.

As before, there is only one entry point and one exit point. Note that in this case, the exit point is not at the end of the pseudocode. Instead,it follows the test.

Perform the test and exit on false

The first thing that happens following entry is that a condition is tested for true or false.

If the test returns false, control simply exits the structure without taking any action at all.

Perform some actions and repeat the test on true

If the test returns true:

  • One or more actions are performed in sequence.
  • The condition is tested again and the process is repeated.

During each iteration, if the test returns false, control exits the structure. If the test returns true, the entire process is repeated.

Each action element may be another structure

Each of the action elements may be implemented by another sequence, selection, or loop structure.

Questions & Answers

what is biology
Hajah Reply
the study of living organisms and their interactions with one another and their environments
AI-Robot
what is biology
Victoria Reply
HOW CAN MAN ORGAN FUNCTION
Alfred Reply
the diagram of the digestive system
Assiatu Reply
allimentary cannel
Ogenrwot
How does twins formed
William Reply
They formed in two ways first when one sperm and one egg are splited by mitosis or two sperm and two eggs join together
Oluwatobi
what is genetics
Josephine Reply
Genetics is the study of heredity
Misack
how does twins formed?
Misack
What is manual
Hassan Reply
discuss biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles
Joseph Reply
what is biology
Yousuf Reply
the study of living organisms and their interactions with one another and their environment.
Wine
discuss the biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles in an essay form
Joseph Reply
what is the blood cells
Shaker Reply
list any five characteristics of the blood cells
Shaker
lack electricity and its more savely than electronic microscope because its naturally by using of light
Abdullahi Reply
advantage of electronic microscope is easily and clearly while disadvantage is dangerous because its electronic. advantage of light microscope is savely and naturally by sun while disadvantage is not easily,means its not sharp and not clear
Abdullahi
cell theory state that every organisms composed of one or more cell,cell is the basic unit of life
Abdullahi
is like gone fail us
DENG
cells is the basic structure and functions of all living things
Ramadan
What is classification
ISCONT Reply
is organisms that are similar into groups called tara
Yamosa
in what situation (s) would be the use of a scanning electron microscope be ideal and why?
Kenna Reply
A scanning electron microscope (SEM) is ideal for situations requiring high-resolution imaging of surfaces. It is commonly used in materials science, biology, and geology to examine the topography and composition of samples at a nanoscale level. SEM is particularly useful for studying fine details,
Hilary
cell is the building block of life.
Condoleezza Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Teaching beginners to code. OpenStax CNX. May 27, 2013 Download for free at http://cnx.org/content/col11498/1.20
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Teaching beginners to code' conversation and receive update notifications?

Ask