Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rotate Array by 1 place left Created by Rojarani #528

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions 2022-Oct/13 Oct 2022/rojarani_akkisetty.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/// C# Program to rotate the array to left by 1 place

using System;

namespace Program
{
public class ArrayRotate
{
public static void Main(String[] args)
{
int n = Convert.ToInt16(Console.ReadLine());

int[] arr = new int[n];
for (int i = 0; i < n; i++)
arr[i] = Convert.ToInt16(Console.ReadLine());

// Storing the first element of array arr[]
// into temp
int temp = arr[0];

// Storing the n - 1 elements of
// array arr[] to the front of arr[]
for (int i = 0; i < n-1; i++)
arr[i] = arr[i+1];

//Storing temp to end of arr[]
arr[n-1]=temp;

//Print the elements of an array
for (int i = 0; i < n; i++)
Console.Write(arr[i].ToString() + " ");

}
}
}