Bubble Sort Algorithm in C

(56 Views)


In this article, we will see very Simple implementation of Bubble Sort Algorithm in C

Simple Bubble Sort Algorithm implementation in C programming language
#include <stdio.h> int main() { int a[]={1,5,3,2,4}; int n=sizeof(a)/sizeof(int); for(int i=0;i<n;i++) { for(int j=0;j<n-1;j++) { if(a[j]>a[j+1]) { int temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; } } } printf("after sorting \n"); for(int i=0;i<n;i++) { printf("%d ",a[i]); } return 0; }

Solution Worked 0 UpvotesUpvote

        

Solution Didn't Worked 0 DownvotesDownvote



Comments



Search