Difference Between While And Do While Loop In C
July 05, 2022 by Primegyan 1.29k
While VS do while in C Programming
| Sr. No. | While | Do While |
|---|---|---|
| 1. | This is a pre tested / top tested / entry control loop. | This is a post tested / bottom tested / exit control loop. |
| 2. | The statements inside the loop are executed only when the condition is correct. | Even if the condition is wrong, at least the loop statements are executed once. |
| 3. | Syntax of while loop : while(condition / exp. ) { statement 1; statement 2; statement n; } |
Syntax of do while loop : do { statement 1; statement 2; statement n; } while(condition /exp. ) ; |
| 4. |
Example of while loop in C : #include |
Example of do while loop in C : #include |