Back to questions
JuniorTheoryCommon
What does the program print (lines separated by spaces)?
Сумма = 0;
Для Сч = 1 По 4 Цикл
Сумма = Сумма + Сч;
КонецЦикла;
Сообщить(Сумма);
Сообщить(Сч);10 5
- Expecting
Счto be 4 after the loop: the counter grows after every pass and leaves the loop at 5 - Expecting the loop counter to exist only inside the loop:
Счis an ordinary variable and is still there after the loop
- What changes if the loop body changes the variable that holds the end value?
- When does a
Покаloop fit better thanДля?