Selection, Iteration & Nesting Flashcards
All 7 cards in this deck
What is nested iteration?
e.g. a loop of 4 stars inside a loop of 3 rows
A loop placed inside another loop; the inner loop runs fully on every pass of the outer loop (here, 12 stars).
Name the three basic programming constructs.
Sequence, selection (choice) and iteration (repetition).
Which construct do the pseudo-code keywords
IF,ELSE IFandELSEbelong to?Selection.
Which construct do the pseudo-code keywords
FOR,WHILEandREPEAT … UNTILbelong to?Iteration.
How is a selection with more than two outcomes written in AQA pseudo-code?
e.g. grade A if score is 80+, B if 60+, otherwise C
- Test the first condition:
IF score ≥ 80 THEN OUTPUT 'A' - Add further tests:
ELSE IF score ≥ 60 THEN OUTPUT 'B' - Catch the rest and close:
ELSE OUTPUT 'C'thenENDIF
- Test the first condition:
What is nested selection?
An
IFstatement written inside theIFbranch or theELSEbranch of anotherIFstatement, so the inner check is only reached when the outer one gives that result, e.g. only checking the password once the username is correct.In programming, what is sequence?
Carrying out statements one after another, in the order they are written, e.g. input a value, then calculate with it, then output the result.