Вопрос задан 17.09.2018 в 03:48. Предмет Информатика. Спрашивает Складчиков Ілля.

Дана последовательность из n действительных чисел .Написать программу для подсчета суммы этих

чисел. Исходные данные n=5 2,3;0;2,5;1,7;-1,5. напишите пожалуйста на английском.
0 0
Перейти к ответам

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Булгакова Мия.
Given a sequence of n real numbers. Write a program to calculate the sum of these numbers. Input n=5 2,3; 0; 2,5; 1,7; -1,5
0 0
Отвечает Кириенко Михаил.
Begin
var sum,i: integer;
sum:=0; 
var a: array [1..5] of integer := (1,5,12,15,47);
  for i:=1 to 5 do
 begin 
 sum:=sum+a[i]; 
 end; 
 writeln('Sum = ',sum);
end.
0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

To calculate the sum of a sequence of real numbers, you can write a program in Python. Here's an example program that calculates the sum of a sequence of numbers:

```python n = 5 numbers = [2.3, 0, 2.5, 1.7, -1.5]

sum = 0 for num in numbers: sum += num

print("The sum of the numbers is:", sum) ```

In this program, `n` represents the number of elements in the sequence, and `numbers` is a list that contains the actual numbers. The program uses a `for` loop to iterate over each number in the list and adds it to the `sum` variable. Finally, it prints the sum of the numbers.

The output of this program, given the sequence `2.3, 0, 2.5, 1.7, -1.5`, would be:

``` The sum of the numbers is: 5.0 ```

Please note that the program assumes the sequence of numbers is stored in a list called `numbers`. You can modify the program to suit your specific needs.

0 0

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

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

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