loops programming review


  • Loops allow a program to repeat tasks automatically without needing to rerun the code each time.

    What makes a while loop useful?

  • What are the parts of a while loop?

    The "while" command, a condition, and a body (the block of code that repeats).

  • When do you use a "do while" loop?

    to execute your body before checking your condition.

  • When do you use a "while" loop?

    when a specified condition is true.

  • When do you use a "for" loop?

    when the iteration is known

    name 3 types of loops

    for

    while

    do while

  • What is an iteration?

    The amount of time a loop runs

  • What is a breakout condition?

    An expression that ends a loop

  • What is a loop?

    A repeated section of code

  • Q: Are brackets required in loops if the body is only one line?

  • A: No, brackets are optional if the body has only one line, just like with conditions.

  • Q: What are i and j commonly used for in loops?

  • conventional names for counters, but they can be named anything.

  • Q: What can the condition in a loop be?

  • A: The condition can be any kind of comparison.

  • Q: Does the incrementor in a loop have to increase by 1?

  • A: No, the incrementor does not have to increment by 1; it can increase or decrease by any value.