Question:I’m having a bit of trouble with this problem. The full text of the problem is as follows : “Write a function that returns a version of the given array of non-negative integers where each zero value in the array is replaced by the smallest odd value to the right of the zero in the array. If there is no odd value to the right of the zero, leave the zero as a zero.”
Here is my code:
myarris the identifier – the name used to refer to the array itself.
myarrhas the type
When used in this expression
is the array subscript operator, accessing index
20. This is index is out of bounds, as the valid indices for the type
19. This out of bounds access will cause Undefined Behaviour.
myarrevaluates to an
int *as its first argument.
Similar to before, in
If you have better answer, please add a comment about this, thank you!