diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e915029 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +################################################################################ +# This .gitignore file was automatically created by Microsoft(R) Visual Studio. +################################################################################ + +/.vs diff --git a/Sorting/Bubble Sort/bubbleSort.c b/Sorting/Bubble Sort/bubbleSort.c new file mode 100644 index 0000000..95e205b --- /dev/null +++ b/Sorting/Bubble Sort/bubbleSort.c @@ -0,0 +1,28 @@ +#include +#include + +public void BubbleSort() +{ + int a[50], n, i, j, temp; + printf("Enter the size of array maximum size allowed is 50: "); + scanf("%d", &n); + printf("Enter the array elements: "); + + for (i = 0; i < n; ++i) + scanf("%d", &a[i]); + + for (i = 1; i < n; ++i) + for (j = 0; j < (n - i); ++j) + if (a[j] > a[j + 1]) + { + temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + + printf("\nArray after sorting: "); + for (i = 0; i < n; ++i) + printf("%d ", a[i]); + + +} \ No newline at end of file