Some situation, we can use while loop or do-while loop interchangeably.
One of my friend told me that such situation we should use do-while loop.
Because it is faster than while.
Can anyone give me proof for it?
Some situation, we can use while loop or do-while loop interchangeably. One of my
Share
Both loops are pretty much the same (except of the fact that a do-while is executed at least once), and in many cases compile to the same instructions, at least on x86.
The following code:
Generates this assembly (using
gcc -S -o temp.as temp.c):