30.while Loop

asilbek_ibragimov_a0c27cc

asilbek ibragimov

Posted on October 14, 2024

30.while Loop

30.while Loop (Advanced)
a) while loopdan foydalanib, foydalanuvchi ragam kiritgancha loopni davom ettirish kodini yozing (masalan, 0 kiritilganda loop tugaydi).
b) Quyidagi kodning natijasi nima bo'ladi?

int x = 10;
while (x > 0)
{
    Console. WriteLine(x);
    x -= 2;
}
Enter fullscreen mode Exit fullscreen mode

Javoblari:

a) 
int num;

while(true)
{
    num = int.Parse(Console.ReadLine());

    if(num == 0)
    {
        break; // 0 kiritilganda loop to'xtaydi
    }
}
Enter fullscreen mode Exit fullscreen mode

b) 10
8
6
4
2

💖 💪 🙅 🚩
asilbek_ibragimov_a0c27cc
asilbek ibragimov

Posted on October 14, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

What was your win this week?
weeklyretro What was your win this week?

November 29, 2024

Where GitOps Meets ClickOps
devops Where GitOps Meets ClickOps

November 29, 2024

How to Use KitOps with MLflow
beginners How to Use KitOps with MLflow

November 29, 2024

Modern C++ for LeetCode 🧑‍💻🚀
leetcode Modern C++ for LeetCode 🧑‍💻🚀

November 29, 2024