Answer to Question #8957 in AJAX | JavaScript | HTML | PHP for Michelle

Question #8957
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.
hint: google for loops vs 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
Expert's answer
A. It's true. for($x = 3; $x<10;$x++) {}. As you can see in brackets we need to specify start value and a terminating condition.
B. It's false. Please, read hint.

C. It's false too, because in third part of definition of the for loop we can define an increment anyway we like. For
examle: $x+=3 or $x*=2;

D. It's true. $x++ equal $x+=1 and equal $x=$x+1.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

New on Blog