﻿ C# - New array after rotating elements in left direction

# C# Sharp Basic Algorithm Exercises: rotate the elements of a given array of integers in left direction and return the new array

## C# Sharp Basic Algorithm: Exercise-92 with Solution

Write a C# Sharp program to rotate the elements of a given array of integers (length 4) in left direction and return the new array.

Test Data: 90, 30, 50, 40
Sample Output: Rotated array: 30 50 40 90
Test Data: -40, 10, -20, -10
Sample Output: Rotated array: 10 -20 -10 -40

Pictorial Presentation:

Sample Solution:-

C# Sharp Code:

``````using System;
namespace exercises
{
class Program
{
static void Main(string[] args)
{

int[] item = test(new[] { 10, 20, -30, -40 });

Console.Write("Rotated array: ");

foreach(var i in item)
{
Console.Write(i.ToString()+" ");
}
}

public static int[]  test(int[] a1)
{
return new int[] { a1[1], a1[2], a1[3], a1[0] };
}
}
}
```
```

Sample Output:

```Rotated array: 20 -30 -40 10
```

Flowchart:

C# Sharp Code Editor:

Improve this sample solution and post your code through Disqus

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.

﻿