While loops are great, but there might be times when you need to do one
particular thing: you want to always execute a block, and then maybe repeat it.

This is done using the do while keyword, in a way that’s very similar to a
while loop, but slightly different:

int i = 0;
do {
/* do something */
} while

The block that contains the /* do something */ comment is always executed at least once, regardless of the condition check at the bottom.

Then, until i is less than 10, we’ll repeat the block.

The do while loop is exactly the same as while loop the difference is that statement execute.

first before checking the condition and always at least one condition will execute if the condition is false.

Syntax Of Do While In C


Note: Semicolon must be included after while in do while loop.

Print Codeverb.com message for 5 times by using do while loop.

#include <stdio.h>
void main()
int i=1;
printf(“Codeverb.com %dn”,i);

Codeverb.com 1
Codeverb.com 2
Codeverb.com 3
Codeverb.com 4
Codeverb.com 5

This article is written by our awesome writer
Comments to: Do while loop in C Programming Language

Your email address will not be published. Required fields are marked *

Attach images - Only PNG, JPG, JPEG and GIF are supported.

New Dark Mode Is Here

Sign In to access the new Dark Mode reading option.

Explore Tutorials By Categories


Welcome to Codeverb

Ready to learn something new?
Join Codeverb!

Read Smart, Save Time
    Strength indicator
    Log In | Lost Password