// Online C compiler to run C program online #include <stdio.h> int main() { int limit,i,j,tmp; int a[1000]; printf("enter the size of an array\n"); scanf("%d",&limit); printf("enter the value of array\n"); for(i=0;i<limit;i++){ scanf("%d",&a[i]); } for(i=0;i<limit-1;i++){ for(j=i+1;j<limit;j++){ if(a[i]>a[j]){ tmp=a[i]; a[i]=a[j]; a[j]=tmp; } } } printf("sorted array\n"); for(i=0;i<limit;i++){ printf("%d,\t",a[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