Learn efficiently and remember over time.
Start Long-Term Learning
Add this set to a folder
int n, triangularNumber;
triangularNumber = 0;
for ( n = 1; n <=200; n = n + 1)
triangularNumber += n;
The 200th triangular number
For loop summary
1. The intial expression is
evaluated first. This expression usually sets a variable that is used
inside the loop, generally referred to as the index variable, to some
intial value (generally 0 or 1)
2. The looping condition is evaluated. If the condition is not satisfied (the expression is false), the loop immediately terminates. Execution continues with the program statement that immediately follows the loop.
3. The program statement that constitutes the body of the loop is executed.
4. The looping expression is evaluated.
5. Return to Step 2
block of code
for (initial expression; loop condition; loop expression)
for loop vs. while loop comparison
while (loop condition)
Tests the loop at the end rather than at the beginning so it runs at least once