15. Write a recursive void function called rotateLeft() with two parameters, an array and an integer count

Question:

15. Write a recursive void function called rotateLeft() with two parameters, an array and an integer count n, that rotates the first n integers in the array to the left. To rotate n items left, rotate the first n – 1 items left recursively, and then exchange the last two items. For example, to rotate the five items 50 60 70 80 90 to the left, recursively rotate the first four items to the left:

60 70 80 50 90 and then exchange the last two items:

60 70 80 90 50 Test it with a main program that takes as input an integer count followed by the values to rotate. Output the original values and the rotated values. Do not use a loop in rotateLeft().

Output the value in the main program, not in the procedure.

Sample Input 5 50 60 70 80 90 Sample Output Original list: 50 60 70 80 90 Rotated list: 60 70 80 90 50

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

Computer Systems

ISBN: 9781284079630

5th Edition

Authors: J Stanley Warford

Question Posted: