void function1(int c[n_cells], int a, int b)
effectively passes a pointer to the caller's array. function1
then operates on the caller's array meaning that any updates are available to the caller.
void function1(int c, int a, int b)
passes a copy of c
. It does not have access to the caller's variable so cannot update it. main
never assigned c
so you print out an uninitialised value.
If you want to update an integer argument, you can pass it by reference instead
void function1(int& c, int a, int b)
// ^
Rather than passing a copy of the caller's c
, this now passes a pointer to the caller's variable, allowing function1
to update it.