DEV Community

Mushtariy
Mushtariy

Posted on

For Loop

a) for loopda continue operatorining ishlatilishini tushuntiring.

Continue - for loopda ishlatiladi continuedan keyingi kod ishlatmaydi va loop keyingi qiymatdan 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;

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 = 0; i <= 10; i++)
        {
            if (i % 2 == 0)
            {
                Console.WriteLine(i);
            }
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

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

Okay