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:
myarr
is the identifier – the name used to refer to the array itself. myarr
has the type int [20]
.When used in this expression
[20]
is the array subscript operator, accessing index 20
. This is index is out of bounds, as the valid indices for the type int [20]
are 0
to 19
. This out of bounds access will cause Undefined Behaviour.This warning
myarr[20]
evaluates to an int
. lowestOdd
expects an int *
as its first argument.Similar to before, in
If you have better answer, please add a comment about this, thank you!