Computer Applications
Answer
The essential parts of a looping control structure are as follows:
- Initialisation — This segment initialises the loop control variable before starting the loop. It is executed only once at the beginning of the loop.
For example,int counter = 1;
- Test-condition — The test-condition is the expression that is evaluated at the beginning of each iteration. Its value determines whether the body of the loop is to be executed (test condition is true) or the loop is to be terminated (test condition is false).
For example,counter <= 10
- Update — This is the increment or decrement operation of the control variable. This operation is performed at the end of each iteration.
For example,counter++ ;
Related Questions
How are these statements different from each other:
(i) break
(ii) continue
(iii) System.exit(0)
What are looping control structures?
Identify all the errors in the following repetitive statements.
while (z < 1 && z > 100) { a = b; }
Identify all the errors in the following repetitive statements.
for (int i = 5; i > 0; i++) { System.out.println("Java"); }