There is not a 'best' loop in
C++
. There are three kinds of loop:
for
,
while
,
do-while
, each one with it pros and cons (forget about relative performance). In my own experience, the most used is
for
.
As a general rule to achieve good performance you have to
- Design (or use an existing) good algorithm.
- Master the programming language.
Proceeding with point (2) you'll notice that 'fastest loop' questions make almost no sense.