Books Question:
11. Which one of the following statements is not equivalent to the other two (assuming that the loop bodies are the same).
a) while ( i < 10 ) {...}
b) for (; i < 10 ; ) {...}
c) do {...} while ( i < 10 ) ;
I think the answer is "c". because both a and b place a condition before running the loop, and c runs the loop first, then checks the conditional. Correct?
11. Which one of the following statements is not equivalent to the other two (assuming that the loop bodies are the same).
a) while ( i < 10 ) {...}
b) for (; i < 10 ; ) {...}
c) do {...} while ( i < 10 ) ;
I think the answer is "c". because both a and b place a condition before running the loop, and c runs the loop first, then checks the conditional. Correct?