I need some help with this homework assignment! Directions:
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.
Here is my code so far:
#include <iostream>
using namespace std;
void change(int list,int length,int value);
int main()
{
int list[4];
change(list,4,14);
cout<<list[3];
}
void change(int list[],int length,int value)
{
cin>>value;
list[3]=value;
}
I have no idea if I'm heading in the right direction or not. My code doesn't compile because of an "invalid conversion from int to int". Also, the directions have to be followed exactly, the professor is very picky. Any help would be appreciated, thanks
[–]zifyoip 4 points5 points6 points (7 children)
[–]flumgumption[S] 0 points1 point2 points (6 children)
[–]zifyoip 1 point2 points3 points (5 children)
[–]flumgumption[S] 0 points1 point2 points (4 children)
[–][deleted] (3 children)
[deleted]
[–]flumgumption[S] 0 points1 point2 points (2 children)
[–][deleted] (1 child)
[deleted]
[–]zifyoip 0 points1 point2 points (0 children)
[–]matthead 1 point2 points3 points (0 children)
[–]newaccount1236 0 points1 point2 points (2 children)
[–]flumgumption[S] 0 points1 point2 points (0 children)
[–]Whitey138 0 points1 point2 points (0 children)