do loop until in c++

Posted under C++ Course On By mohammed.mutawe

Do loop until

In the C++ language, there are many types of iterative loops, which are based on executing the code block inside it without stopping except by closing the condition. New to be achieved and stop the sentence.

 

Definition

As we said earlier, the iterative do while statement is usually defined to execute a block of code inside it until the execution condition is met, and the general syntax of the do while statement is:

do {
  // excude code
}
while (condition);

 

The do while clause differs from the for loop clause, the first one starts executing directly until it collides with the condition below it, while the for loop clause is based on the principle of specifying the condition at the beginning and then taking over the execution, and as we mentioned its formula previously, it is based on the principle, do that while

 

Example

Please, to understand the do while well, copy the following code into your code editor.

#include <iostream>





int main()
{
    int x = 0;

    do
    {
        std::cout << "Hello World\n";

        x++;

    } while (x<=20);



    std::cout << "\n";
    system("PAUSE");

    return 0;
}

 

 

 

Leave a comment

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