Home TechnologyProgramming Subscribe to RSS

What Is Basic Difference Between While Loop And Do-while Loop?

Define it clearly?

Answer Question

14 Answers - Sort by: Date | Rating

    A do while loop runs at least once even though the the condition given is false
    while loop do not run in case the condition given is false
    1 0
    Guest

    Guest  

    answered 8 months ago

      In a while loop the condition is first tested and if it returns true then it goes in the loop, while in a do-while loop the it enters the loop 1st and does the 1st iteration and then does the checking at the end.... If at the end in a do-while loop it returns true the 2nd iteration follows , but if it returns false then it goes out of the loop...
      1 0

      Ashamul  

      answered 5 months ago

        In while loop first condition is check if it is not true than iteration is takes palace but in do while loop after first iteration condition is check either it is true or false.
        1 0
        Guest

        Guest  

        answered 5 months ago

        Rule of use identifier
        0 0
        Guest

        Guest  

        answered 6 months ago

        1. In While loop the condition is
        tested first and then the statements are executed if the condition turns out to
        be true.
        In do while the statements are executed for the first time and then the conditions
        are tested, if the condition turns out to be true then the statements are
        executed again.

        2. A do while is used for a block
        of code that must be executed at least once.
        These situations tend to be relatively rare, thus the simple while is more commonly
        used.

        3. A do while loop runs at least once
        even though the the condition given is false
        while loop do not run in case the condition given is false



        4. In a while loop the condition is
        first tested and if it returns true then it goes in the loop

        In a do-while loop the condition is
        tested at the last.



        5. While loop is entry control loop
        where as do while is exit control loop.



        6. Syntax:



        while loop  :

        while (condition)

        {

        Statements;

        }

        do while loop  :

        Do

        {

        Statements;

        }while(condition);

        0 0

        Amolnakhwa  

        answered 3 months ago

          Difference between while loop and do-while loop
          0 0
          Guest

          Guest  

          answered 3 months ago

          Do while check codition first then execute.
          Whlie loop execute codition first
          0 0
          Guest

          Guest  

          answered 3 months ago

          While loop test condition before statement execution
          do while test condition after statement execution
          0 0
          Guest

          Guest  

          answered 3 months ago

          In-case of while loop the given condition is checked and the statement of loop will be executed if the condition found to be true.
          But At Do-while loop the given statement will be executed atleast once and thereafter the condition will be checked. And if condition founds false the execution stops.
          This is the BAsic difference between while loop and do-while loop.

          And I hope this will help you.
          See you.
          0 0
          Guest

          Guest  

          answered 2 months ago

          -In while loop condition testing is done in the beginning of the loop execution each time
          -In do while condition testing is done after running the loop each time
          0 0

          Guest  

          answered 2 weeks ago

            In a  do while loop runs at least once even though the the given condition is false but in while loop do not run in case the given condition  is false.the while testes the condition before executing any of the statement within the while loop.the do-while loop tests the condition after executed the statement  within the loop.
            0 0

            Mohanjoshi  

            answered 1 week ago

            In general both the while loop and do-while loop are iterative control structures in any programming language. Both are conditional loops because these are based on conditions (Boolean expressions). The value of Boolean expression (true /false) determines whether the loop exits or not.

            But there is a little difference in their way of iterating.  The basic difference is in the time of checking the condition during execution of loop. In while loop the condition is checked at the start, if it is true then statements enclosed in the loop structure are executed , otherwise the loop exits and control transfers to the statements following this loop and  this process continues until the condition becomes false.
            As:             
                                  While (condition)
                                   {
                                       statement1;
                                       statement2;
                                                .
                                                .
                                    }
            Statements following the loop;


            But in the case of do-while loop condition is checked at the end of structure (i.e., at least one time the statements enclosed in this loop structure are executed before checking the condition)
            After executing the loop statements at least once, the loop condition is checked; if it is true then the loop body is executed again otherwise loop exits. As:
                                     Do
                                     {
                                        statement1;
                                        statement2;
                                                .
                                                .
                                      }
                                      While (condition)
            Statements following the loop;
            Thus ,their syntax shows clearly how these two loops are different from each other.
            0 1

            Raaga  

            answered 3 years ago

            While loop is entry control loop where as do while is exit control loop.


            while=> condition of loop is checked first befor executing the body of loop.

            Do while=>  condition of loop is checked after executing the body of loop.i.e loop execute at least once.
            It is mainly used in menu like programmes where all the available choices are printed at least once.
            0 1

            Gaurav1212  

            answered 3 years ago

            In while loop after checking the condition the loop executes or exits based on the condition result.But in the do-while loop first the statements enclosed with the loop executes and then it checks the condition.
            0 1
            Guest

            Guest  

            answered 7 months ago

            More

               
               

              Ask a Question via Twitter

              Send a question to @askblurtit and we will publish it online and send you a reply everytime you receive an answer.

              Blurtit Store

              Get T-shirts, hoodies, caps and more at the Blurtit store

              Blurtit International