DEV Community

Mushtariy
Mushtariy

Posted on

For Loop

a) for loopda break operatori ganday ishlatiladi? Misol keltiring.

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

b) Quyidagi kod natijasini tushuntiring.

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

javob - 0,1,2,3,4,5,6 break i 7 ga teng bo'lganida to'xtaydi.

Top comments (0)