Programming Constructs Flashcards
What is Sequence?
A series of steps which are completed one after the other. In a flow diagram they are shown as process, input and output symbols shown one after the other.
What is Selection?
The ability to choose different paths through a program. In flowcharts, decision symbols are used for selection.
What is Iteration?
Repeating a part of a program. It is also referred to as repeating or looping. In flowcharts, iteration is shown using arrows that repeat a section of the flowchart and a decision will control more iterations are required.
Understanding Sequence
01 - First of all do this line of code 02 - Now do this one 03 - Now do this one 04 - Now do this one 05 - And this one 06 - And finally this one
Understanding Selection
01 - First of all do this line of code 02 - Now do this one 03 - IF (Age > 18) THEN 04 - Do this line of code 05 - And now this one 06 -And now this one 07 - ELSE 08 - Do this line of code 09 - And now this one 10 - And now this one
Which two sub categories does iteration fall into?
1) Count Controlled Loops (run a set number of times)
2) Condition Controlled Loops (run forever - or until a condition is met)
Understanding Iteration - Count Controlled Loops
01 - First of all do this line of code 02 - Now do this one 03 - For 1 to 10 time DO 04 - Do this line of code 05 - And now this one 06 -And now this one 07 - And now this one 08 - END LOOP 09 - Now do this line 10 - And finally this one
Understanding Iteration - Condition Controlled Loops
01 - First of all do this line of code 02 - Now do this one 03 - REPEAT all the lines of code below 04 - This one 05 - And this one 06 -And this one 07 - And this one 08 - UNTIL (Age > 18) 09 - Now do this line 10 - And finally this one