DEV Community

Mushtariy
Mushtariy

Posted on

While Loop

a) While loop va do while loop o'rtasidagi farqni tushuntiring.

while - 1 chi bo'lib shart tekshiriladi keyin shart bajariladi.
do while - 1 chi bo'lib shart bajariladi so'ng shart tekshiriladi.

b) Quyidagi while loop qanday ishlayd va natijasi nima bo'ladi?

int x = 0;

while(x < 3)
{
    Console.WriteLine(x);
    x++;
}
Enter fullscreen mode Exit fullscreen mode

loop 3 marta aylanadi x ning qiymati 0 qachonki x ning qiymati 3 dan kichkina eng kotta songa teng bo'lsa ya'ni 2ga loop to'xtaydi loop har aylanganda x ga 1 ni qo'shib ketadi va natijani chiqaradi.

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay