Continue Operator
Overview
The continue operator transfers control to the beginning of the next iteration of the nearest enclosing loop (while, do-while, or for). Its functionality is the inverse of the break operator.
Syntax
continue;
Behavior
continue immediately terminates the current iteration.Usage
Example
// Sum of all nonzero elements
int func(int array[]) {
int array_size = ArraySize(array);
int sum = 0;
for (int i = 0; i < array_size; i++) {
if (array[i] == 0) continue; // Skip if element is zero
sum += array[i];
}
return sum;
}
Related Concepts
while, do-while, for.