Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
Bubble Sort - The easiest sort in C language
SUBMITTED BY:
Neutrino
DATE:
Dec. 10, 2020, 3:38 a.m.
FORMAT:
Text only
SIZE:
444 Bytes
Raw
Download
Tweet
HITS:
493
Go to comments
Report
#include<stdio.h>
int main(void)
{
int i,n,temp,j,arr[10];
printf("\nEnter the no of elements in the array ");
scanf("%d",&n);
printf("\nEnter the elements ");
for(i=0;i<n;i++)
{scanf("%d",&arr[i]);}
for(i=0;i<n;i++)
{
for(j=0;j<n-i-1;j++)
{if(arr[j]>arr[j+1])
{
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}
printf("\n The array sorted in ascending order ");
for(i=0;i<n;i++)
{printf("%d\t",arr[i]);}
return 0;
}
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus