21. for Loop
Zahro
Posted on October 16, 2024
a) for loopda continue operatorining ishlatilishi
continue operatori for loopda ishlatilganda, hozirgi iteratsiya o'z yakuniga yetmaydi va keyingi iteratsiyaga o'tadi. Bu shart bajarilganda tsiklning qolgan qismi o'tkazib yuboriladi va for loopning keyingi bosqichiga o'tiladi.
Misol:
for (int i = 0; i < 5; i++)
{
if (i == 2)
{
continue;
}
Console.WriteLine(i);
}
b) Quyidagi kodning natijasini ayting:
for (int i = 0; i < 5; i++)
{
if (i == 2)
{
continue;
}
Console.WriteLine(i);
}
Natija:
0
1
3
4
c) for loopdan foydalangan holda, 1 dan 10 gacha bo`lgan juft sonlarni ekranga chiqaruvchi kod yozing.
for (int i = 1; i <= 10; i++)
{
if (i % 2 == 0)
{
Console.WriteLine(i);
}
}
💖 💪 🙅 🚩
Zahro
Posted on October 16, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
githubcopilot AI Innovations at Microsoft Ignite 2024 What You Need to Know (Part 2)
November 29, 2024