CodersEditor Tutorials

CodersEditor Tutorials

  • Online IDE
  • Q&A
  • C Programming
  • Java
  • GraphQL.NET
  • System Software

›Loop

C Programming

    Introduction

    • Overview
    • Installation & Setup
    • C Program Structure
    • Keywords & Identifiers
    • Data Types
    • Variables & Constants
    • Scope Rules
    • Storage Class
    • Standard Input and Output
    • Operators

    Control Flow/Decision Making

    • Overview
    • if Statement
    • if else Statement
    • Nested If statement
    • Switch Statement
    • Nested Switch Statement
    • Conditional Operators

    Loop

    • Loops Overview
    • While loop
    • For Loop
    • Do while
    • Nested Loops
    • Break
    • Continue Statement
    • Goto statement

    Arrays

    • Arrays
    • Multi Dimensional Arrays
    • Arrays & Functions

    Pointers

    • Pointers Basics
    • Pointers and Arrays
    • Pointers and Functions
    • Memory allocation

    Strings

    • String Basics
    • String Functions

    C Programming Examples

    • Basic Example 1

Do while loop in C

In this article you will get to know about the do..while loop in C programming and the usage of it.

Do while loop in C

The function of do….while loop is similar to while loop but with a change in the structure, the do….while loop in C programming checks the condition at the bottom of the loop.

A do...while loop is guaranteed to execute at least one time.

A do….while loop is just like an inverted while loop. It is used in the situations where you know that the code contained in the body of the loop should always need to be executed at least once.

Unlike while loop, even when the condition is false, the do…while loop will be executed once.

Syntax

do
{
//statements inside the body of the loop
}
while (condition);

Example

#include<stdio.h>
int main(){
    int x = 1;
    int y = 5;
    do{
        printf("%d ", x);
        ++x;
    }while (x <= y);
    return 0;
}

Output

1 2 3 4 5
← For LoopNested Loops →
  • Do while loop in C
  • Syntax
  • Example
CodersEditor Tutorials
CoderdEditor Developer Tools
CodersEditor Online EditorGit Flavoured Markup EditorFree Online JSON FormatterFind My IP Address Details
Tutorials
C ProgrammingJava
Copyright © 2021 CodersEditor.com