Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Ask user for array size, have user input values for the array, ask user how much to rotate array program in C++ Question 2 of
Ask user for array size, have user input values for the array, ask user how much to rotate array program in C++
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 rotate By): 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 submissionStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started