The answer
Yes, variables declared in the initialization step (like 'int i') are scoped only to that loop and disappear when the loop finishes.
Yes, variables declared in the initialization step (like 'int i') are scoped only to that loop and disappear when the loop finishes.
Use a for loop when you know exactly how many times you need to iterate, such as when traversing an array of known length.
It is the increment operator. It means 'increase the value of i by 1' after each iteration of the loop.
Yes. You can initialize the counter at a high value, use a greater-than condition, and decrement the counter (e.g., i--).
Browse all our FAQs or reach out to our support team
Your learning library
Find your next course. Build something great.