DEV Community

Sunnat Qayumov
Sunnat Qayumov

Posted on

3 2 2 2 2

21. for Loop

a) for loopda continue operatorining ishlatilishini tushuntiring.

continue operatori for loopda ishlatilganda, bu shuni anglatadiki, continuedan keyingi kod ishlatilmaydi va loop keyingi qiymatni olib ishlashni davom ettiradi.

*b) Quyidagi kodning natijasini ayting: *

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

*Javob: * 0, 1, 3, 4, 5.

c) for loopdan foydalangan holda, 1 dan 10 gacha bo'lgan juft sonlarni ekranga chiqaruvchi kod yozing.

class Program
{
    static void Main()
    {
        for (int i = 1; i <= 10; i++)
        {
            if (i % 2 == 0)
            {
                Console.WriteLine(i);
            }
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay