Вопрос задан 02.05.2019 в 10:16. Предмет Информатика. Спрашивает Иванов Паша.

Исправьте ошибки во фрагменте программы: n:=1; while n<=10 write('n=', n:5); еnd;

0 0
Перейти к ответам

Ответы на вопрос

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Шкраба Александр.
Если после n<=10 поставить do, а вместо end; - end., то получится зацикливание, что не есть хорошо. Возможно, имелось в виду это:
var n:integer;
begin;
n:=1;
while n<=10 do
begin;
n+=1;
write('n=', n:5);
end;
end.
Вариант с зацикливанием( но это будет конец программы):
n:=1;
while n<=10 do
write('n=', n:5); 
end.
Вариант если учитель быдлокодер:
n:=1;
while n<=10 do
begin;
write('n=', n:5); 
end;
0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

Fixing Errors in the Program Fragment

The given program fragment contains a few errors that need to be addressed. Let's go through the code and correct the mistakes.

The original code provided is: ``` n:=1; while+n<10 write('n=', n:5); еnd; ```

Corrections:

1. The "while" statement should be followed by "do" to indicate the start of the loop. 2. The "write" statement should be followed by a semicolon to separate it from the next statement. 3. The "end" statement should be "end;" to properly terminate the loop.

Corrected Program Fragment:

``` n := 1; while n <= 10 do begin write('n=', n:5); n := n + 1; end; ```

In the corrected code: - The loop starts with the value of `n` set to 1. - The "while" loop continues as long as `n` is less than or equal to 10. - Inside the loop, the value of `n` is printed with the label 'n=' and a width of 5 characters, and then `n` is incremented by 1.

This corrected code should properly iterate through the values of `n` from 1 to 10 and display them with the label 'n='.

Feel free to let me know if you have any further questions or need additional assistance!

0 0

Топ вопросов за вчера в категории Информатика

Последние заданные вопросы в категории Информатика

Задать вопрос