OneCompiler

Control Structures (Loops)

137

Loop Structure: A programming construct that allows for the repeated execution of a block of code as long as a specified condition remains true.
Finite Loop Structure: A loop that executes a predetermined number of times. Examples: for loops.
Sentinel Loop Structure: A loop that continues executing until a specific sentinel value is encountered. Examples: while and do...while loops.
for loop: Used when the number of iterations is known beforehand. It consists of initialization, condition, and increment/decrement parts.
while loop: Used when the number of iterations is not known beforehand. The condition is checked before each iteration.
do...while loop: Similar to the while loop, but the condition is checked after each iteration, ensuring the code block executes at least once.
break statement: Immediately exits the loop.
continue statement: Skips the current iteration and proceeds to the next.