DEV Community

madina1575
madina1575

Posted on

DO WHILE LOOP

do while loop - while loopning bir turi.

do while loop ham while loop bilan bir xil funksiyani bajaradi ammo while loop agar sharti to'g'ri bo'lmasa ichiga kirmaydi, do while loop da sharti to'g'ri bo'masa ham bir marta ishlaydi.

Sinteks:
do
{
statement;
increasment/decreasment;
}while(expression)

Masalan:

#include <iostream>

using namespace std;

int main()
{
    int i = 15;
    do
    {
        cout << "Hello World" << endl;
        i++;
    }while(i <= 10)
}
Enter fullscreen mode Exit fullscreen mode

bu yerda i 15 ga teng yani 10dan katta va shartga to'g'ri kelmaydi ammo u bir marta Hello World tekstini chiqarib beradi.

Top comments (0)