Back To C++ Basic Index
//program to demonstrate bubble sort on a single dimensional array (program sorts the array in ascending order) #include
#include
void main() { int arr[5]={50,52,40,30,31}; int i,j,temp; clrscr(); for(i=0;i<5;i++) { for(j=0;j<4;j++) { if(arr[j]>arr[j+1]) { temp=arr[j]; arr[j]=arr[j+1]; arr[j+1]=temp; } } } for(i=0;i<5;i++) { cout<