Bifalgorithm post · Computer science one · For Loops

How do do-while loops differ from while loops in C?

How do do-while loops differ from while loops in C? (Computer science one · For Loops) — "17.3. Do-While Loops\n\nC supports do-while loops. Recall that the di…

Ideas in this flowchart

  • Do-while loops in C
  • C supports do-while loops.
  • The key difference from a while loop is when the continuation condition is checked.
  • In a while loop, the condition is checked before the loop body begins.
  • In a do-while loop, the condition is checked at the end of the loop.
  • A do-while loop always executes at least once.
  • An example appears in Code Sample 17.4.
  • The opening curly bracket is on the same line as the do keyword.
  • The while keyword and continuation condition are on the same line as the closing curly bracket.
Feed/

How do do-while loops differ from while loops in C?

No cover

Channel

Computer science one

1 page

"17.3. Do-While Loops\n\nC supports do-while loops. Recall that the difference between a while loop and a do-while loop is when the continuation condition is checked. For a while loop it is prior to the beginning of the loop body and in a do-while loop it is at the end of the loop. This means that a do-while always executes at least once. An example can be found in Code Sample 17.4. Note the syntax and style: the opening curly bracket is again on the same line as the keyword do. The while keyword and continuation condition are on the same line as the closing curly bracket. In a slight departure from prior syntax, a semicolon does 285"

Flowchart preview
👍
0
0 comments0 shares

Sign in to view and post comments.