Computer Applications

What are loop control structures? What are the essential segments of a loop control structure?

Java Iterative Stmts

2 Likes

Answer

A loop is a set of instructions that is continually repeated until a certain condition is met. Looping control structures refer to certain looping constructs which execute a block of code repeatedly until a certain condition remains true. For example, for loop, while loop, do - while loop etc.

The essential parts of a looping control structure are as follows:

  1. 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;

  2. 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

  3. 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++;

Answered By

1 Like


Related Questions