ICSE Class 8 Computer Studies Question 1 of 10

Decision Control Structure — Question 2

Back to all questions
2
Question

Question 2

What are the unique features of for loop?

Answer

for loop is an entry-controlled loop. Its general syntax is as follows:

for (initialization; conditional; increment/decrement)  
{  
    //Java Statements  
    ..  
    ..  
}
  1. The initialization expression initializes the loop control variable and is executed only once when the loop starts. It is optional and can be omitted by just putting a semicolon.
  2. The conditional expression is tested at the start of each iteration of the loop. Loop will iterate as long as this condition remains true.
  3. The increment/decrement expression updates the loop control variable after each iteration.
  4. The body of the loop that consists of the statements that needs to be repeatedly executed.