The for loop combines initialization, condition, and update in one line. It's perfect for counting when you know the iteration range upfront. For loops are more compact than while for counting tasks.
Instead of three separate lines, you write one: for (int i = 0; i < 5; i++). Use for when you know the number of iterations. Use while when the number depends on runtime conditions like user input or file length.