Which are true about for loops? A. You need to specify the start value and a terminating condition. For example: the loop start with $x = 3 and ends when $x is less than 10 B. They are exactly the same a while loops. C. On each iteration of the for loop, the indexing variable usually, $i, if always incremented by 1 D. $i++ means $i = $i + 1
Anyone else think B and D?
There are varying nuances for each language, but in general you need to set an initial value and a test condition. Quite often when using for loops you will increment your indexing variable. Although not exclusive to for loops, i++ does mean to take the value of i and add 1 to it. The 'for' loop differs from a 'while' loop in that no initial condition is set, the loop runs for as long as the condition is true.
I would not be thinking B. :P
I actually didn't put B ended up with just D lol
A and C are probably the most accurate, D is commonly used in for loops but it is not exclusive to them like the conditional statements are.
Join our real-time social learning platform and learn together with your friends!