31.do while Loop (Advanced)

sunnat_qayumov

Sunnat Qayumov

Posted on October 16, 2024

31.do while Loop (Advanced)

a) do while loopda foydalanuvchi noto'g'ri parolni kiritganda, takroran parol so'raydigan kodni yozing (parol to'g'ri bo'lsa, loop to'xtaydi).

string To'g'ri = "12345";
string Tahmin;

do
{
    Console.Write("Parolni kiriting: ");
    Tahmin = Console.ReadLine();

    if (Tahmin != To'g'ri)
    {
        Console.WriteLine("Noto'g'ri parol! Qayta urinib ko'ring.");
    }
Enter fullscreen mode Exit fullscreen mode

b) Quyidagi kodning natijasini tushuntiring:

int y = 0:
do
{
    Console.WriteLine(y);
    y++;
}while(y < 5);
Enter fullscreen mode Exit fullscreen mode

*Javob: *

0
1
2
3
4
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
sunnat_qayumov
Sunnat Qayumov

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