java

Cards (19)

  • A loop is a control structure that executes a part of the code repeatedly based on a given condition.
  • Iteration is a term that describes each loop cycle.
  • The loop body contains the block of code that needs to be executed when the boolean expression returns to true.
  • A definite loop is a loop with a known or defined iteration.
  • The indefinite loop is where the iteration count is not initially specified and can only be determined when the program is run.
  • An infinite loop is a never-ending loop.
  • The pretest loop is where it evaluates the control variable before executing the loop body.
  • In contrast, the posttest loop is the one that runs the loop body first before testing the loop control variable.
  • In writing a definite loop, you have to give an initial value to the loop control variable and set the condition where the block of code inside the body gets executed if the boolean value is true.
  • The increment or decrement operator will be responsible for calculating each iteration count that updates the value of the control variable.
  • The syntax for a while loop is: while (boolean expression).
  • In writing a while loop, you have to give an initial value to the loop control variable and set the condition where the block of code inside the body gets executed if the boolean value is true.
  • The syntax for a for loop (count-controlled loop) is: for (initialization; condition; increment/decrement operation).
  • After the keyword for, there are three sections inside the parenthesis: initialization, condition, and increment/decrement operation.
  • The for loop will stop when the condition is satisfied.
  • In a do-while loop, the loop body is executed first before checking if the loop condition is true.
  • In a nested loop, a loop is employed inside another loop.
  • The inner loop in a nested loop is also considered as a loop body of the outer loop.
  • The nested loop will stop when the outer loop’s condition is satisfied.