This content originally appeared on DEV Community and was authored by Mahamadjon000
Цикл for - используется выполнения кода заданное количество раз.
Внутри for можно создавать переменые.
Пример кода:
#include <iosream>``
using namespace std;
int main()
{
for(int i = 1; i <= 5; i++)
{
cout << "Number" << i << endl;
}
return 0;
}
Обьяснение кода:
int i = 1 - переменная i значением 1.
Условия - int <= 5 цикл будет выполняться пока i меньше или равно 5.
i++ - после каждой итерации значение i увеличивается на 1.
This content originally appeared on DEV Community and was authored by Mahamadjon000
Mahamadjon000 | Sciencx (2024-11-02T09:56:27+00:00) for loop. Retrieved from https://www.scien.cx/2024/11/02/for-loop/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.