Asked by
AL MaMun (4 Golds)
Friday, 31 Jul 2020, 04:51 PM
at (Education
Tutorials)
|
|
|
|
Bubble sort C program : #include<stdio.h> int main() { int a[100], i, j, k, n; scanf("%d", &n); for(i=0; i<n; i++) scanf("%d", &a[i]); for(i=0; i<n; i++) printf("%d ", a[i]); printf("\n\n"); for(i=0; i<n; i++) { for(j=n-1; j>=i+1; j--) { k=a[j-1]; if(a[j-1]>a[j]) { a[j-1]=a[j]; a[j]=k; } } } for(i=0; i<n; i++) printf("%d ", a[i]); } |