Page 229 - CA_Blue( J )_Class9
P. 229
14 break;
15 case 2: for(i=2;i<=10;i=i+2)
16 { System.out.print(i+"/"+(i+2)+" + "); }
17 break;
18 default: System.out.println("Wrong Choice");
19 }
20 }
21 }
You will get the following output:
Let’s Revisit
A loop has three parts, initialisation, condition and increment.
Initialisation is a process in which a variable is initialised that helps the loop to execute.
A loop has a condition that is tested every time the loop is executed.
The increment, takes the execution of the loop one step ahead, the increment helps to reach a terminating condition to
end the loop.
There are three types of loop in Java; for loop, while loop and the do-while loop.
A loop that never terminates is known as an infinite loop.
For loop and while loop are entry controlled loop as the condition is tested before the control enters the loop
body.
Do-while loop is known as exit controlled loop as the condition is checked while the control exits the loop body.
A break statement is used to terminate the execution of the loop or switch statement in which it is placed.
The continue statement makes the control skip the current iteration and move on to the next iteration of the loop.
Iterative Constructs in Java 227

