Bobble Sort method to sort the given numbers (ascending to descending)

 #include<stdio.h>

#include<conio.h>

int main()
 
 {
     int x[10],i,n,t,j;
   
     printf("Enter size of an array\n");
     scanf("%d",&n);
     printf("Enter array element\n");
     for (i=0;i<n;i++)
      scanf("%d",&x[i]);
      for (i=0;i<n-1;i++)
     
      {
          for (j=0;j<n-1;j++)
           {
               if (x[j]>x[j+1])
               {
                   t=x[j];
                   x[j]=x[j+1];
                   x[j+1]=t;

               }
           }
      }
      printf("sorted List\n");
      for (i=0;i<n;i++)
        printf("%d\n",x[i]);
        return 0;
      }

Comments

Popular posts from this blog

Maths Unit 1 ( Theory )

Intelligence System notes part 2

code for find the determinant of 3x3 matrix