DEV Community

Mahamadjon000
Mahamadjon000

Posted on

1

for loop

Цикл for - используется выполнения кода заданное количество раз.

Внутри for можно создавать переменые.

Пример кода:

#include <iosream>``

using namespace std;

int main()
{
for(int i = 1; i <= 5; i++)
{
cout << "Number" << i << endl;
}

return 0;
}
Enter fullscreen mode Exit fullscreen mode

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

int i = 1 - переменная i значением 1.

Условия - int <= 5 цикл будет выполняться пока i меньше или равно 5.

i++ - после каждой итерации значение i увеличивается на 1.

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more