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)

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