C program for Bubble Sort

#include<stdio.h>#include<conio.h>int main(){     int a[10]={};        int temp,j,i,x;     printf("Please Enter Array element MAX:10n");     for(i=0; i<=9; i++)     {              scanf("%d",&a[i]);     }     printf("nn Unsorted Array is :");     for(i=0; i<9; i++)     {              printf(" n a[%d]= %d",i,a[i]);                   }          for(j=0; j<=9; j++)     {      for(i=0; i<=9-j; i++)      {       if(a[i] >= a[i+1])              {              temp=a[i];              a[i]=a[i+1];              a[i+1]=temp;              }              }       printf("nn Iteration %d :",j);       for(x=0; x<=9; x++)        {          printf(" %d ",a[x]);          }                                       }         printf("nn Sorted Array is :");   for(i=0; i<=9; i++)   {     printf(" %d ",a[i]);     } getch();  }

 

Comments

Popular posts from this blog

MATLAB code for Circular Convolution using Matrix method

Positive number pipe in angular 2+