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;
}
bu yerda natija quyidagicha bo'ladi:
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1
Top comments (0)