DEV Community

Mushtariy
Mushtariy

Posted on

do while Loop

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 parol = "lalalala";
string javob;

do
{
    Console.Write("Parolni kiriting: ");
    javob = Console.ReadLine();
}while (javob != parol);
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 - 1,2,3,4 loop 4 marta aylanda va har aylanganda y ni chiqarib ketadi y 0 ga teng y qachon 5dan kichkina eng katta songa teng bo'lsa loop toxtidi

Top comments (0)