Question: Exercise 4: Inspect the following code. Give the correct version of the code /*The function moveElements permits to move the first nbElem elements of an
Exercise 4: Inspect the following code. Give the correct version of the code /*The function moveElements permits to move the first nbElem elements of an array arr to the end of the array. */ void moveElements(int arr[],int n,int nbElem) { int i,j,temp; for (i = 0; i < =nbElem; i++) { temp = arr[0]; for(j=1; j<=n-1; j++) { arr[j] = arr[j+1]; } arr[n] = temp; } } illustration Original Array: [10, 17, 6, 3, 12, 1, 4, 8, 0, 2] After moving nbElem=3 elements: [3, 12, 1, 4, 8, 0, 2, 10, 17, 6]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
