Answer the question
In order to leave comments, you need to log in
Adding numbers from a loop?
Help me please!
It is necessary to calculate the sum of all numbers in a given interval, inclusive. If the beginning of the interval exceeds the end, then it is necessary to perform the calculation in the reverse order. For example, the sum of numbers from 1 to 5 is 1+2+3+4+5=15 and vice versa 5+4+3+2+1=15 using a loop.
How to write correctly, otherwise I can’t do it ..
Thank you.
Answer the question
In order to leave comments, you need to log in
Compare numbers.
If a > b, then loop from b to a.
And vice versa.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question