Вопрос задан 25.02.2019 в 10:12. Предмет Информатика. Спрашивает Сидоров Андрей.

Помогите пожалуйста Программа в Паскале написать Уменьшение положительного числа на 1 до тех

пор,пока оно не станет отрицательным. Как только число становится отрицательным,команда повторения заканчивает свою работу
0 0
Перейти к ответам

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Назаров Даниил.
Var n:Integer;
Begin 
Read(n); 
while (n>=0) do
  begin 
   n:=n-1; 
  end;
Writeln('Finished');
end.
0 0
Отвечает Вяткина Полина.
 var   
a : integer;    
begin 
readln (a);
//Цикл с условием
//Он выполнятся пока верно его условие (a>=0)   
While a >= 0 do 
 a := a - 1; 
writeln (a); 
end.
0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

Writing a Pascal Program to Decrease a Positive Number by 1 until it Becomes Negative

To write a Pascal program that decreases a positive number by 1 until it becomes negative, you can use a repeat-until loop. Here's an example program:

```pascal program DecreaseUntilNegative; var number: integer; begin writeln('Enter a positive number:'); readln(number); repeat number := number - 1; until number < 0; writeln('The number has become negative:', number); end. ```

In this program, we declare a variable `number` of type `integer` to store the positive number. The user is prompted to enter a positive number, which is then read and stored in the `number` variable.

The `repeat-until` loop is used to continuously decrease the value of `number` by 1 until it becomes negative. The loop condition `number < 0` checks if the number has become negative. If it hasn't, the loop continues to execute the statement `number := number - 1`, which decreases the value of `number` by 1.

Once the loop condition becomes true and the number becomes negative, the loop terminates, and the program displays the final value of `number`, which should be negative.

You can run this program in a Pascal compiler or IDE to see the output. Remember to save the file with a `.pas` extension, such as `decrease_until_negative.pas`, before compiling and running it.

I hope this helps! Let me know if you have any further questions.

0 0

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

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

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