public static void Main()
int[] arr = { 5, 2, 4, 3, 1 };
Console.WriteLine("Original Array:");
Console.WriteLine("\nSelect a sorting algorithm:");
Console.WriteLine("1. Bubble Sort");
Console.WriteLine("2. Selection Sort");
Console.WriteLine("3. Insertion Sort");
Console.WriteLine("4. Print the Array");
Console.WriteLine("5. Exit");
int choice = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Invalid Choice!");
static void BubbleSort(int[] arr)
for (int i = 0; i < n - 1; i++)
for (int j = 0; j < n - i - 1; j++)
Console.WriteLine("\nArray after Bubble Sort:");
static void SelectionSort(int[] arr)
for (int i = 0; i < n - 1; i++)
for (int j = i + 1; j < n; j++)
if (arr[j] < arr[minIndex])
Console.WriteLine("\nArray after Selection Sort:");
static void InsertionSort(int[] arr)
for (int i = 1; i < n; i++)
while (j >= 0 && arr[j] > key)
Console.WriteLine("\nArray after Insertion Sort:");
static void PrintArray(int[] arr)
for (int i = 0; i < arr.Length; i++)