What is do while loop in C Programming Language ?

 

do while loop in c

In this article we will be going to discuss the last topic of loop which is do while loop in which following points are included ,

  • What is do while loop in C
  • Syntax of do while loop in C
  • Example of do while loop in C

What is do while loop in C ?

The 'do...While' assertion(statement) is also used for looping. The body of this loop may additionally comprise a single statements or a block of statements. here firstly the statements inside loop body are executed and then the condition is evaluated. If the condition is true then the loop frame is carried out and this process keeps till the condition turns into false.

Note:-

Unlike while loop,here a semicolon is located after the condition.

Syntax of do while loop


  do
{
    Statement 1;
    Statement 2;
    Statement 3;
    .
    .
    Statement n;
}
  while(condition);

Example of do while statement

// Program to print digit from 1 to 10

#include<stdio.h>
int main ()
{
int i=1;
do
{
printf("%u\t",i) ;
i=i+1;
}
while(i<=10) ;
printf("\n") ;
return 0;
}
_____________________________________________________________

example of do while loop in c
_____________________________________________________________

Conclusion

In this article we have learned about do while loop in detail, I hope after reading this article you have no any doubt left, but still if you have any queries then feel free comment below.

_________________________________________
  • Nested do while statement

Post a Comment (0)
Previous Post Next Post