Previous Next
0 / 21
Module DEMO-32-106DEMO-C-32

Left Rotate Array

DEMO-C-32 โ€ข Programming in C

Browser-only practice

Problem Statement

Write a C program to left rotate the elements of an array by 1 position. The first element should move to the last position, and all other elements should shift one position to the left. Input n and the integers, then display the rotated array.

Example

Input:

5 1 2 3 4 5

Output:

2 3 4 5 1

Constraints

1 <= n <= 100

Input Format

n and array

Output Format

Left rotated array

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
5
1 2 3 4 5
2 3 4 5 1
1 moves to end.
Sample #2
Public sample
1
100
100
Single element, no change visually.

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings