118k views
1 vote
When would the associated code block be executed for the statement: do {code block} while (condition)?

Once at the beginning of the loop, and then if the condition is false
Once if the condition is true, and then once after the loop is done
Once if the condition is false, and twice if the condition is true
Once at the beginning of the loop, and then if the condition is true

User Nnythm
by
5.3k points

1 Answer

6 votes

Answer:

Once at the beginning of the loop, and then if the condition is true

Step-by-step explanation:

  • This is a general do-while loop.
  • Minimum lifetime is 1 time and maximum lifetime is infinity.
  • Firstly the code in the do bracket runs without any condition.
  • The condition present in the while bracket tells the do bracket to run after the first time.
  • If the condition is false the module ends.
  • For while condition = true it sends the compiler back to do operation until the while condition becomes false.
User Gary Storey
by
6.6k points