There are several problems here. First, at line 7,
the variable counter is defined but it is not initialised, hence its value is garbage. It should be given some initial value, zero makes sense from the context.
Next, at line 14, the return statement is odd. The function
has been defined with a return type of
which means it will be able to return a single value of type int.
return theArray, counter;
should be simply:
And finally, in function main() at line 29, a rather strange assignment statement,
myArray, counter = secondFunction ( myArray, 9 );
which should be simply
counter = secondFunction ( myArray, 9 );
It think that should fix things reasonably well. Though function
is still a little puzzling, as it receives the parameter
but does not use it, and instead has a hard-coded value of 7 in the for loop.