Easy csharp

DS — reverse array [1, 2, 3, 4, 5] #81

Problem

Reverse array in-place concept; print reversed.

Hints
  • Swap i and n-1-i

Your solution

TestStatusDetails
Ready — edit the code above and click Run or Submit.

Solution

using System;

class Program
{
    static void Main()
    {
        int[] a = { 1, 2, 3, 4, 5 };
        Array.Reverse(a);
        Console.WriteLine(string.Join(" ", a));
    }
}

Try solving on your own first, then reveal the official answer.

Explanation

Array.Reverse or two-pointer swap.

Discussion

0

Sign in to join the discussion.

No discussions yet — ask the first question!

Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details