Loading...
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
The most common loop in DSA. Ideal when you know exactly how many times to iterate. All three parts — init, condition, update — live in one line.
int i = 0→ init oncei < n→ check each iterationi++→ update after bodyfor (int i = 0; i < n; i++) {
cout << i << " ";
}for (int i = n-1; i >= 0; i--)for (int i = 0; i < n; i += 2)for (int i=0, j=n; i<j; i++, j--)