Search⌘ K

Example 65: Rotate an Array

Explore how to rotate the elements of a one-dimensional integer array to the left by a specified number of positions in C. Learn to implement and understand a function that repeatedly shifts array elements, reinforcing your skills in array manipulation and function usage.

Problem

Write a function that rotates left the contents of a 1D array of integers by the desired number of places.

Example

Suppose an array named arr contains the following elements:

arr[] = {1, 2, 3, 4, 5, ...