#include<stdio.h> int main() { int n=6,i,j,temp,flag; int arr[n] = {60,34,76,23,89,29}; for(i=0;i<n-1;i++){ flag = 0; for(j=0;j<n-1;j++){ if(arr[j]>arr[j+1]){ temp = arr[j]; arr[j] = arr[j+1]; arr[j+1] = temp; flag = 1; } } if(flag==0){ break; } } for(i=0;i<n;i++){ printf("%d ",arr[i]); } return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter