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)

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

👋 Kindness is contagious

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

Okay