A
A
Amakamui2021-08-20 22:34:54
C++ / C#
Amakamui, 2021-08-20 22:34:54

Adding array elements?

Hello, how can I add array elements, for example, from 2 to 4 At the same time, the number with index 2 is not
taken into account in the sum, but 4 is taken into account 10,13,4,-8];

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2021-08-20
@Amakamui

In this case, the number with index 2 is not taken into account in the amount, and 4 is taken into account

That is, from 3 to 4 inclusive.
var numbers = [1,-3,5,-6,-10,13,4,-8];
var sum = numbers[3..4].Sum();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question