I hope this is the correct forum. I'm trying to learn the basics of programming.
There is something I'm not sure if I fully understand.
One of the general requirements of a sequence structure is that there may not be any branches or loops between the entry and the exit. This is the part I'm confused about. A psedocode example for sequence structues is:
enter
perform one or more actions in sequence
exit
There is also a note that says the action elements may themselves be sequence, selection or loop statements. I do understand this, I think. The code below shows that.
An example of this would be the Selection Structure in the code below, It is one of the elements in a sequence structure.
What would be an example (possibly using the code below) that would show me what it looks like to have a branch or loop that is NOT ALLOWED between the entry and the exit of the sequence structure? This code is from a program called Alice, which helps people learn the basics of programming. testResult and userInputValue are variables.
CODE
// Uses if-else to test a user input value for even or odd.
// Get user input.
userInputValue set value to ( ask user for a number question = Enter an integer. )
// Compute remainder after dividing by 2 and return true
// if remainder is equal to 0
testResult set value to ( ( IEEERemainder of userInputValue / 2 ) == 0 )
// Execute the selection structure.
If testResult
penguin say Even duration = 30 seconds
Else
penguin say Odd duration = 30 seconds
I guess I'm just trying to understand or visually see what it means when it says:
There may not be any branches or loops between the entry and the exit. This is the part I'm confused about. I'm taking a free tutorial that is online.
This post has been edited by legend_018: 22 Sep, 2008 - 05:21 PM