DEV Community

madina1575
madina1575

Posted on

WHILE LOOP

loop -halqa dep tarjima qilinadi.

Looplar c++ dasturlash tilida biror ishni qayta qayta bajarish uchun ishlatiladi.

Looplardan biri bo'lgan while loop ni o'rganamiz.

Sinteks:

while(expression)
{
statement;
increasment/decreasment;
}

Masalan:

#include <iostream>

using namespace std;

int main()
{
    int i = 50;
    while(i >= 1)
    {
        cout << "Hello World" << endl;
        i--;
    }
}
Enter fullscreen mode Exit fullscreen mode

bu yerda i o'zgaruvchisi orqali Hello World tekstini 50 marta chop eta olamiz. While loop ga birinchi marta kirganda bitta Hello World tekstini chop etadi va bittaga kamayadi chunki i-- decreasment qo'yilgan.

Top comments (0)