Remove Negatives
Create a function named “removeNegatives”. Its parameters are an array of integers and the size of the array. It has the return type of int.
The function must remove all negative values in the array, modify the value of size variable, and return the sum of the remaining values. Below is an example of how the array should look like before and after calling the function.
Before:
INDEX | 0 | 1 | 2 | 3 | 4 | 5 | 6 |
---|---|---|---|---|---|---|---|
ELEMENT | 4 | -2 | 6 | 1 | -3 | -9 | -5 |
- SIZE: 7
After:
INDEX | 0 | 1 | 2 | 3 | 4 | 5 | 6 |
---|---|---|---|---|---|---|---|
ELEMENT | 4 | 6 | 1 | - | - | - | - |
- SIZE: 3
- Previous
- Next