for is a keyword and the usage changes slightly from language to language. In C/C++ it has the following syntax:
for ([INITIALISATION]; [CONDITION]; [INCREMENT]) [INSTRUCTION]
where
- INITIALISATION is typically setting up the start conditions of the for loop.
- CONDITION is typically a logical expression to check whether the for loop should keep running (exit when it fails).
- INCREMENT is typically an instruction to increment a loop variable for the next iteration of the loop
- INSTRUCTION is the body of the loop to execute in every iteration
an actual example would be like this:
for (int i = 1; i <= 10; i++)
{
printf("The %dth square number is: %d\n", i, i * i);
}