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
#include
main () {
    int a = 1;
    while( a < 10 ) {
        printf("a = %d\n", a);
        a++;
        }
getch();
}

Example of do while loop in C :

#include
#include
main () {
    int a = 1;
    do {
        printf("a = %d\n", a);
        a++;
        }while( a < 10 );
getch();
}