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

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




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.



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.


Топ вопросов за вчера в категории Информатика
Последние заданные вопросы в категории Информатика
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili