AS SSD Program Control Structures Flashcards
(26 cards)
How does a program run?
It runs in sequence.
What is used to disrupt the sequence of a program?
Methods are used.
What must a method have?
It must have a name an a body of code.
How it code within a method executed?
Code within a method is executed in sequence.
Where should every method be called?
In the predefined “Main” method.
What is repetition?
Repetition, which is also called iteration is the idea of repeating blocks of code a certain number of times or until a condition is met.
What are the 4 main types of iteration?
For, While, Do-While and For-Each.
When should a For Loop be used?
A For Loop can be used if the number of iterations of the loop is known to the user.
What is a for-each loop?
A for-each loop will execute some code depending on how many items are in a data structure, such as a list or array.
What is not a requirement when using a for-each loop?
It is not a requirement to know how many times you have to loop through a list or array.
What is a while loop?
A while loop will repeat something until a condition is met. These are most useful when you aren’t sure how many times something has to be repeated.
What logical operators can be used in a while loop?
Any logical operator can be used and it can also have single or multiple conditions.
What is a do-while loop?
A do-while loop will always ensure that the code inside the loop will execute at least once before checking the condition.
What is a do-while loop considered as?
It is considered as a “post-test” loop as it checks the condition after running the code once.
What is an if statement?
An if statement is used when there are multiple conditions which must be checked and one of which must be true in order to execute a price of code.
What is this logical operator?
Equal to
What is this logical operators?
!=
Not equal to
What is this logical operators?
>
Greater than
What is this logical operator?
>=
Greater than or equal to
What is this logical operators?
<
Less than
What is this logical operators?
<=
Less than or equal to
What is this logical operators?
&&
And
What is this logical operators?
||
Or
Why might you use a nested if statement?
It allows you to control the program flow within an if statement.