- loop control instructions are used to control the flow of execution within loops.
- These instructions allow you to alter the normal behavior of loops and provide more fine-grained control over the loop's execution.
- for loop
- while loop
- do while loop
- The for loop is used when you know exactly how many times you want to repeat a block of code.
- It consists of an initialization statement, a conditional expression, and an increment statement, and it continues to execute the code block until the conditional expression becomes false.
- The while loop is used when you want to repeat a block of code while a certain condition is true.
- It consists of a conditional expression, and the code block continues to execute as long as the expression is true.
- The do-while loop is similar to the while loop, except that the code block is executed at least once, regardless of whether the conditional expression is true or false.
- It consists of the do keyword, followed by the code block, and then the while keyword and the conditional expression.
- 2 operators: 1) ++i (Pre Increment) 2) i++ (Post Increment)
- 2 operators: 1) --i (Pre Decrement) 2) i-- (Post Decrement)
- It is possible to use float or character data types as loop counters.
- infinite loop is a loop that continues to run indefinitely or until interrupted by an external action.