Вопрос задан 16.02.2019 в 23:36. Предмет Информатика. Спрашивает Микитюк Маша.

ПОМОГИТЕ ПРОШУ ,ОДИН НОМЕР НЕ МОГУ РЕШИТЬ Написать программу для решения задачи. Дано целое число.

Если оно является положительным, то прибавить к нему 1; в противном случае не изменять его. Вывести полученное число
0 0
Перейти к ответам

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Олексійчук Вікуля.
If a>0 then
a:=a+1
Else write a
0 0
Отвечает Кочанова Ангелина.
Var a:integer;
Begin
Readln(a);
If a>0 then
a:=a+1;
If a<0 then
a:=a+0;
Writeln(a);
End.
0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

Program to Add 1 to a Positive Integer

Here's a Python program that solves the given problem:

```python def add_one_to_positive(num): if num > 0: num += 1 return num

# Test the function integer = int(input("Enter an integer: ")) result = add_one_to_positive(integer) print("Result:", result) ```

In this program, we define a function called `add_one_to_positive` that takes an integer as input. Inside the function, we check if the number is positive (`num > 0`). If it is, we add 1 to it. Finally, we return the modified number.

To test the program, we ask the user to enter an integer using the `input` function. We then call the `add_one_to_positive` function with the user's input and store the result in the `result` variable. Finally, we print the result.

Please note that this program assumes the input will be a valid integer. If you need to handle invalid input, you can add error checking or validation code.

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

0 0

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

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

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