do while Loop

do-while loop

do-while Loop

A do-while loop is similar to while loop, but the fact that it is guaranteed to execute at least one time.

Syntax

        
do 
{
    statement(s);
}
while (condition);         
        
    

Program

        
#include <stdio.h>
int main ()
{
    int num = 10;
/* do loop execution */
do
{
    printf("value of a: %d\n", a);
    num = num + 1;
}
while( num < 20 );

return 0;
}
                             
        
    

Output

        
Value of num : 10
Value of num : 11
Value of num : 12
Value of num : 13
Value of num : 14
Value of num : 15
Value of num : 16
Value of num : 17
Value of num : 18
Value of num : 19            
        
    



Join Our Social Media Connections

Post a Comment

0 Comments