-2

What's the easiest way to understand "which type of loop should you use?" when targeting for efficiency.

do...while loop while loop for loop

Thank you

c0d3rl0l
  • 1
  • 1

1 Answers1

0

I haven't coded in C for a while (pan not intended). There are some slight differences.

do... while - will execute code at least once, even when the condition is not met.

while - will execute code for any condition given until it is not true.

for - will give you a more readable standardized way to iterate some code as you can see the step, the condition, and the breaking value in the same line.

There are more details in this post: For vs. while in C programming?