Вопрос задан 09.01.2020 в 01:25. Предмет Информатика. Спрашивает Решетникова Настя.

СРОЧНО СРОЧНО СРОЧНО ПОЖАЛУЙСТА ПОМОГИТЕ вводится десятичное число. написать программу, которая

вычесляет количество десятков и единиц в вводимом числе. Программа должна вывести на экран сообщение: "в числе десятков= , в числе единиц= ".
0 0
Перейти к ответам

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Лукашевич Дима.
Var n:integer;
begin
write('n = ');
readln(n);
writeln('в числе десятков = ',n mod 100 div 10);
writeln('в числе единиц = ', n mod 10);
end.

Пример:
n = 125
в числе десятков = 2
в числе единиц = 5
0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

Program to Calculate the Number of Tens and Units in a Decimal Number

Here is a program in Python that calculates the number of tens and units in a decimal number:

```python decimal_number = float(input("Enter a decimal number: ")) tens = int(decimal_number // 10) units = int(decimal_number % 10) print("Number of tens =", tens) print("Number of units =", units) ```

Explanation: 1. The program prompts the user to enter a decimal number using the `input()` function. 2. The input is converted to a float using the `float()` function to handle decimal numbers. 3. The number of tens is calculated by dividing the decimal number by 10 using the `//` operator, which performs integer division. 4. The number of units is calculated by taking the remainder of the decimal number divided by 10 using the `%` operator. 5. The results are printed using the `print()` function.

Please note that this program assumes the input is a decimal number. If the input is an integer, the program will still work, but the number of tens will be 0.

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

0 0

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

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

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