Introduction
C Programming
C Advanced
Important C Programs
Modal Box
Tutorials
Do while loop
In do while loop, body of the loop is executed first and after that, the condition is checked.
Do while loop executes at least once even if the condition is not true a single time.
Syntax for do while
do
{
// body statement to be executed
}
while (condition here);
Example
#include <stdio.h> #include <conio.h> int main() { int i=1; do { printf("This will execute once even the condition is false"); } while(i<0); }
⇒ In the above case, the condition is false from the beginning but loop still executes once.
Video/ C Introduction
Watch video in full size