DEV Community

madina1575
madina1575

Posted on

NESTED WHILE LOOP

Nested so'zi - ichma - ich degan ma'noni bildiradi.

Nested while loop - while loop ichida xyana boshqa while loop ishlatish imkonini beradi.

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

Masalan:

#include <iostream>

using namespace std;

int main()
{

    int son = 5;
    int son2 = 5;

    while(son >= 1)
    {
        while(son2 >= 1)
        {
            cout << son2 << " ";
            son2--;
        }
        cout << endl;
        son--;
    }

    return 0;
}
Enter fullscreen mode Exit fullscreen mode

bu yerda natija quyidagicha bo'ladi:
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1

Top comments (0)