DEV Community

Mahamadjon000
Mahamadjon000

Posted on

1 1 1 1 1

while loop

Loop - это Петля.

while - это цикл который повторяет выполнение кода пока заданное условие остаётся true.

Если false то оно закачивается.

Пример кода:

#include <iostream>

using namespace std;

int main()
{
int number = 1;

while (number <= 5)
 {
    cout << "Numbers: " << number << endl;
    number++;
}

return 0;
}
Enter fullscreen mode Exit fullscreen mode

Обьяснение код:

  • Цикл выводит значение переменой number начиная с 1.

  • number++ - значение увеличивается на 1.

  • Как только number стоновится больше 5 number <= 5 стоновится False и цикл зовершается.

Top comments (0)

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay