Loop Basics
Mix of Loop Basics and For Loop
For Loop
100

What is a loop in programming?

A structure that repeats a block of code while a condition is true.

100

What does i++ do in a for loop?

What is increment i by 1?

100

What part of the loop determines when it stops running?

What is the condition?

200

What is the index of the last element in an array of size 5?

What is 4?

200

What does .length return when used with an array?

What is the number of elements in the array?

200

What are the three parts of a for loop header?

What are initialization, condition, and update?

300

What do you call a loop that never ends?

An infinite loop.

300

Why is using < instead of <= safer in array loops?

What is to stay within bounds?

300

Fix the error:
 for(int i = 1; i <= 5; i--)

Change i-- to i++ to avoid infinite loop.

M
e
n
u