Home » Blog » do…while Loop In C

do…while Loop In C

As discussed before, loop contains three part

  • Intialization
  • Condition Checking
  • Incrementation Or Decrementation

do…while loop is also called exit control loop, it means that the statement of loop are always executed once even if the condition is false. In this while is ended by semicolon(;).


	variable++; or variable--;
	//increment or decrement

Example is given below


void main()
    int i = 10;     // declaration and initialization at the same time

    do // do contains the actual code and the updation
        printf("i = %d\n",i);
        i = i-1;    // updation
    }while(i > 0);
    printf("\n\The value of i after exiting the loop is %d\n\n", i);


i= 10
i= 9
i= 8
i= 7
i= 6
i= 5
i= 4
i= 3
i= 2
i= 1

The value of i after exiting the loop is 0


Leave a Reply

Your email address will not be published.