Loops in C
π C
π 28 views
π
Dec 22, 2025
β± Estimated reading time: 1 min
Loops are used to execute a block of code repeatedly as long as a specified condition is true.
Types of Loops in C
-
forloop -
whileloop -
doβwhileloop
1. for Loop
Used when the number of iterations is known.
Syntax
Example
2. while Loop
Used when the condition is checked before execution.
Syntax
Example
3. doβwhile Loop
Used when the loop must execute at least once.
Syntax
Example
Differences Between Loops
| Feature | for | while | doβwhile |
|---|---|---|---|
| Condition check | Before loop | Before loop | After loop |
| Minimum execution | 0 times | 0 times | At least 1 time |
| Use case | Known count | Unknown count | Execute once minimum |
Loop Control Statements
break
Terminates the loop.
continue
Skips the current iteration.
Nested Loops
A loop inside another loop.
Summary
-
Loops repeat execution of statements
-
forloop is used for fixed iterations -
whileloop checks condition first -
doβwhileloop executes at least once -
breakandcontinuecontrol loop flow
π Some advanced sections are available for Registered Members
Register Now
Register Now
Share this Post
β Back to Tutorials