for (int i=0; i <= 255; 1){
//instruction here ;
}
Technically it is valid (compilable) code, but highly unusual. If the instructions in the loop modify the var i it can be a finite loop. Otherwise it will be infinite.
for (int i=0; i <= 255; a++){
//instruction here ;
}
Same here as above, with the remark that - the var a - must be declared and initialized before the loop and it will increment with the number of times the for loop is executed, still unusual, but it might just do exactly what you need
Beginning students often stumble on for loops because of the order of processing. The syntax of the for loop:
for (expression1; expression2; expression3) {
// Loop Statement Body: one or more statements controlled by the for loop
}
// First statement after closing for loop brace
where:
expression1: often used to initialize a variable that controls the loop. This expression is only executed once, when the loop first begins.
expression2: often a relational test that evaluates to True or False. If True, the Loop Statement Body is executed. If False, program continues with the statement following the closing for loop brace.
expression3: If expression2 was logic True, when the Loop Statement Body completes, control is sent to expression3. Often this statement changes the state of the variable initialized in expression1.
If neither expression3 or statements in the Loop Statement Body do not change the state of the loop and expression2 was True when the loop began, expression2 will always be True,
resulting in an infinite loop.