hey everyone I am currently working on a homeworking that requires using dynamic arrays.
it is supposed to take in numbers and stops when it reads a negative one.
It has to calculate the sum of the first and the last number(not negative)in the array then calculates the second and the second last and so on...
the remaining number has to be dubbled.
for example: 4 3 5 1 7 -1
output: 11,4,10.
im always getting negative rubish with this code.
a dynamic array is not a suitable container for this exercise, what if a negative number is not entered before the array runs out of size? can you use std::vector?
edit:
it is supposed to take in numbers and stops when it reads a negative one.
to make it work with a dynamic array this condition has to be an either or - either it reads a negative one or it runs out of size
thanks I'll following your advice, i now understand my mistake. But will it not affect the answer when calculating the remaining number of the array without the negative number?