C++ Question Needs Aswers

I need help with this question, please. I'm a beginner.

Question: Write a function change that accepts an int array as the first parameter, and another int parameter for the length of that array and an int value as a third parameter. The function will store the integer value into the last element of the array. The original array SHOULD change. As an example, given the array
int x = {5, 4, 9, 42};
The following call to your function change
change(x, 4, 14);
should change the value of the last element of the array to 14.

Comments

  • This is what I could come up with but it's not correct;

    int change(int x [], int length, int value)
    {
    X [length-1] = &value;
    Return x [];
    }

  • void change(int x[], int len, int val) {
      x[len-1] = val;
    }
    
  • Hey iam a beginner 'i need to know different btn privet and public in c++ and when we use them

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories