You're developing a function that modifies an array of integers. To ensure that the original array is not altered, how should the array be passed to the function?

  • Pass a copy of the array
  • Pass a pointer to the array
  • Pass by reference
  • Pass by value
To ensure that the original array is not altered, you should pass a pointer to the array to the function. This way, the function can work with the original data without making a copy of the array. Pass by reference typically involves languages like C++ and is not a direct concept in C. Pass by value would create a copy of the array, which is not the desired behavior. Passing a copy of the array would have the same effect as passing by value.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *