iteration

3.2.2 d

 * ===understand and use iteration in pseudo-code and a procedural programming language, including the use of count-controlled loops (FOR-NEXT loops) and condition-controlled loops (DO-WHILE and REPEAT-UNTIL loops);===


 * == Keyword == || == Definition == ||
 * Iteration || A group of instruction that are repeated executed for a select number of times or until a condition is met. ||
 * Pseudo-code || A method of describing a program or system and design which uses similar keywords and phrases found in programming languages but without the strict rules of programs. ||

Iteration is a programming technique when a line or a selection of lines of code must be executed continuously until a condition is met, it is also known as a loop. The three types of loops are: For-Next loops, Do-While Loops, and Repeat-Until loops. =For Loop= Loop=0 For( Loop, <6, Loop + 1) Output = “Loop is” +Loop This will add 1 to the Loop continuously until it is equal to <6, which is until the Loop is equal to 5 then it will output that the Loop is equal to 5. || In Java Script Loops follow a very simple construct which means that they are also simple. Here is a full algorithm For a For Loop in Java Script. class forLoop { public static void main (String[]args) { //initialise loop counter variable int num=0; for(int i=1; i<6; i++) { System.out.println(“Loop is =” +i); } } } This Loop will add 1 to the value of i until it is <6 then output the line after each line, the output will look something like this: Loop is =1 Loop is =2 Loop is =3 Loop is =4 Loop is =5 || =Do-While Loops=
 * Pseudo Code || Java Script ||
 * In pseudo code For Loops are very simple, an example will provide the best description of a For Loop in pseudo code.

Loop=0 Do (System.out.println("number is " + num)); ++num; While( Loop, <6, Loop + 1) || In Java Script the principal of a While-Endwhile loop is the same, condition is checked at the beginning then updated. class doWhileLoop { public static void main (String[]args) { //initialise loop counter variable int num=0; do { System.out.println("number is " + num); ++num; } while (num < 10); } } The output would look something like this: Number is 0 Number is 1 Number is 2 Number is 3 Number is 4 Number is 5 Number is 6 Number is 7 Number is 8 Number is 9 ||
 * Pseudo Code || Java Script ||
 * A while-Endwhile Loop will check for a condition at the beginning of the program then update the condition for which it will need to end.

=Repeat-Until Loops=
 * Pseudo Code || Java Script ||
 * A Repeat-Until loop is a loop that will execute a number of statements until a condition is met. Is very similar to a for loop but a for loop does the loop a set number of times and a repeat until loop can execute an infinite number of times until a condition is met. || In Java Script the principal of a Repeat-Until loop is the same, that the loop executes a number of statements until a condition is met. ||

02 input key 03 move character according to the key input 04 until the end of the platform is reached
 * === EXAM QUESTIONS === || === MARKS === || === PAPER === ||
 * 01 repeat

3) a) i) describe what iteratation ii) describe two types of iteration constructs other than that of the pseudo code used above || 3) a) i)2 ii)4 || January 2010 3) a) i) ii) ||