public static void Main()
int[] array = {64, 34, 25, 12, 22, 11, 90};
Console.WriteLine("Sorted Array: ");
public static void BubbleSort(int[] array, int n)
for (int i = 0; i < n - 1; i++)
for (int j = 0; j < n - 1; j++)
if(array[j] > array[j+1])
Console.WriteLine("Array position " + j + " is greater than array position " + (j + 1));
Console.WriteLine("Initiating swap");
Console.WriteLine("Swapping array position " + j + " for array position " + (j + 1));
Console.WriteLine("Array position " + j + " has been moved to temp");
Console.WriteLine("var temp value is " + temp);
Console.WriteLine("Swapping the values between the array positions...");
Console.WriteLine("Swap successfully completed. Value " + array[j] + " is at position " + j + ". Value " + array[j+1] + " is at position " + (j + 1));
if (swapped == false && jCount >= array.Length)
public static void printArray(int[] arr, int size)
for (i = 0; i < size; i++)
Console.Write(arr[i] + " ");