From 186d14e4c266d4eb52714e1c953c728fbd42f2ee Mon Sep 17 00:00:00 2001 From: JAY BHATIA Date: Sun, 4 Oct 2020 17:02:43 +0530 Subject: [PATCH 1/3] Added Bubble sort --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .gitignore 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 From a86072bb991733a3a6c46de418074b9a8201318c Mon Sep 17 00:00:00 2001 From: JAY BHATIA Date: Sun, 4 Oct 2020 17:03:09 +0530 Subject: [PATCH 2/3] added Bubble sort --- Sorting/Bubble Sort/bubbleSort.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Sorting/Bubble Sort/bubbleSort.c diff --git a/Sorting/Bubble Sort/bubbleSort.c b/Sorting/Bubble Sort/bubbleSort.c new file mode 100644 index 0000000..971345d --- /dev/null +++ b/Sorting/Bubble Sort/bubbleSort.c @@ -0,0 +1,27 @@ +#include +#include +void main() +{ + 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 From 9feae2f2d2c34c8f4e2d0d94134fcc02bb0b4e73 Mon Sep 17 00:00:00 2001 From: JAY BHATIA Date: Mon, 5 Oct 2020 22:08:32 +0530 Subject: [PATCH 3/3] Created Function insted of Main function for bubble sort --- Sorting/Bubble Sort/bubbleSort.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sorting/Bubble Sort/bubbleSort.c b/Sorting/Bubble Sort/bubbleSort.c index 971345d..95e205b 100644 --- a/Sorting/Bubble Sort/bubbleSort.c +++ b/Sorting/Bubble Sort/bubbleSort.c @@ -1,6 +1,7 @@ #include #include -void main() + +public void BubbleSort() { int a[50], n, i, j, temp; printf("Enter the size of array maximum size allowed is 50: ");