/* Program to demonstrate MODIFIED bubble sort */ #include #include void bubble(int x[ ], int n) ; void show(int x[ ], int n) ; void main() { int i, n, x[20] ; clrscr() ; printf("Enter the number of elements: ") ; scanf("%d",&n) ; printf("Enter the elements:\n") ; for(i=0 ; ix[j+1]) { temp=x[j] ; x[j]=x[j+1] ; x[j+1]=temp ; flag=1 ; } show(x,n) ; } } /* For descending order use x[j]x[j+1] */ /* This is modified bubble sort. There is something called classical bubble sort also. Modified bubble sort has the ability to terminate the function earlier if the array gets sorted before reaching the last pass. To convert modified bubble sort to classical bubble sort, just remove all the statements related with flag */ void show(int x[ ], int n) { int i ; for(i=0 ; i