23. Do While Loop
Zahro
Posted on October 16, 2024
a) Do while loop qachon ishlatiladi?
do while loop shartdan qat'i nazar, kodni kamida bir marta bajarish kerak bo'lganda ishlatiladi. Masalan, foydalanuvchidan ma'lumot olishda yoki biron bir kodning kamida bir marta ishlashiga ishonch hosil qilish zarur bo'lsa.
b) Quyidagi kodning natijasini tushuntiring:
int i = 5;
do
{
Console.WriteLine(i);
i++;
} while (i < 5);
Bu kodda i dastlab 5 ga teng. Shart tekshirilmasdan avval, i qiymati ekranga chiqariladi. Keyin i birga oshiriladi va shart i < 5 tekshiriladi. Shart noto'g'ri, shuning uchun loop yana takrorlanmaydi.
Natija:
5
💖 💪 🙅 🚩
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
watercooler Why does a reboot make your PC run SO much faster than running all the cleaning tools you can possibly imagine?
November 30, 2024