Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Sorting/Bubble Sort/bubbleSort.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include<stdio.h>
#include<conio.h>
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]);


}