DEV Community

Sanjar Rashidov
Sanjar Rashidov

Posted on

Nested while loop

Nested while loop - while loop ichida yana boshqa while loop ishlatish.

Syntax of nested while loop:
while(condition)
{
while(condition)
{
statement
++/--
}
statement
++/--
}

Masalan:

#include <iostream>

using namespace std;

int main()
{
    int n = 1;

    while(n <= 1)
    {
        while(n <= 7)
        {
            cout << n << endl;
            n++;
        }
        cout << endl;
        n++;
    }

    return 0;
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)