Skip to content

Commit

Permalink
bubblesort algorithms in c Yathartha22#5
Browse files Browse the repository at this point in the history
  • Loading branch information
aman05382 authored Oct 15, 2019
1 parent cbae36b commit 7acbead
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Sorting Algorithms/bubblesort.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include<stdio.h>

int main()
{
int a[50],n,i,j,temp;
printf("Enter the size of array: ");
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]);

return 0;
}

0 comments on commit 7acbead

Please sign in to comment.