DEV Community

Zahro
Zahro

Posted on

29.for Loop(Advenced)

a) For loopda break operatori qanday ishlatiladi? Misol:

break operatori loopni to'xtatish uchun ishlatiladi. Misol:

for (int i = 0; i < 10; i++)
{
    if (i == 5)
    {
        break; 
    }
    Console.WriteLine(i);
}
Enter fullscreen mode Exit fullscreen mode

Bu kodda i qiymati 5 bo'lganda, loop to'xtaydi. Natija:

0
1
2
3
4

b) Quyidagi kod natijasi:

for (int i = 0; i < 10; i++)
{
     if (1 == 7)
     {
         break;
     }
    Console.WriteLine(i);
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)