Loops

A loop statement allows us to execute a statement or group of statements multiple times.

whileloop.png
Below is a table listing the different types of loops in the C language.
Loop Type Description
while loop Repeats a statement or group of statements while a given condition is true.
It tests the condition before executing the loop body.
for loop Executes a sequence of statements multiple times and abbreviates
the code that manages the loop variable.
do … while loop Like a while statement, except that it tests the condition at the end of the loop body.
nested loops You can use one or more loops inside any other while, for, or do..while loop.
© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.