fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int bubble_sort(int A[],int n)
  4. {
  5. int i,j,temp;
  6.  
  7. for(i=1;i<n;i++)
  8. { for(j=0;j<n-1;j++)
  9. {
  10. if(A[j]>A[j+1])
  11. temp=A[j];
  12. A[j]=A[j+1];
  13. A[j+1]=temp;
  14. }
  15. }
  16.  
  17.  
  18. }
  19.  
  20.  
  21.  
  22. int main()
  23. {
  24. int A[]={3,9,1,5,8},n=5;
  25. /*printf("enter the total number of elements");
  26.   scanf("%d",&n);
  27.   printf("enter the Array");
  28.   for(int i=0;i<n;i++)
  29.   {printf("\n");
  30.   scanf("%d",&A[i]);
  31.   }*/
  32.  
  33. bubble_sort(A,n);
  34. for(int k=0;k<n;k++)
  35. {
  36. printf("%d ",A[k]);
  37. }
  38. }
  39.  
Success #stdin #stdout 0s 9432KB
stdin
Standard input is empty
stdout
8 1769956920 9 9 9