Question: Question 2 of 3. Rotate Array Left: [30 marks] Write a program with function(s), that rotates the elements of the array to the left for

Question 2 of 3. Rotate Array Left: [30 marks] Write a program with function(s), that rotates the elements of the array to the left for a given number of elements. Array Rotation Example: Example 1: Input Array: [3, 4, 5, 6, 7] Rotate left by 1 element: Resultant array: [4, 5, 6, 7, 3] Example 2: Input Array: [3, 4, 5, 6, 7] Rotate left by 2 elements: Resultant array: [5, 6, 7, 3, 4] Example 3: Input Array: [3, 4, 5, 6, 7] Rotate left by 3 elements: Resultant array: [6, 7, 3, 4, 5] Example 4: Input Array: [3, 4, 5, 6, 7] Rotate left by 2 elements: Resultant array: [7, 3, 4, 5, 6] Your program will take an array as an input from the user. Write a function called RotateArray() that takes the array as a parameter and updates the array with the rotated elements. Please use the following function declaration. void RotateArray(int array[], int size, int rotateBy); Your function should NOT print the rotated array. It should rotate the given array, which will then be printed in the main function. Remember that arrays are always passed as references. Therefore, we need to update the int array[] parameter with the rotated values. Make sure your code works for any input number/array, not just the test cases. Your code will be tested on other test cases not listed here. You need to assume a maximum array size of 20 Please properly comment your code before submission. For this part of the assignment, name your source file as RotateArray_WSUID.cpp. For example, if your user ID is A999B999 name your file as RotateArray_A999B999.cpp.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!