#include<stdio.h>
#define size 10
void bubblesort(int *,const int );
int main()
{
int a[size]={8,4,5,7,4,5656,7842,641,47,12,7};
int i;
printf("date items in original order\n");
for(i=0;i<size;i++)
printf("%4d",a[i]);
bubblesort(a,size);
printf("\nData items in ascending order\n");
for(i=0;i<size;i++)
printf("%4d",a[i]);
printf("\n");
return 0;
}
void bubblesort(int *array,const int size)
{
void swap(int *,int *);
int pass,j;
for (pass=0;pass<size-1;pass++)
for(j=0;j<size-1;j++)
if(array[j]>array[j+1])
swap(&array[j],&array[j+1]);
}
void swap(int *element1Ptr,int *element2Ptr)
{
int hold=*element1Ptr;
*element1Ptr=*element2Ptr;
*element2Ptr=hold;
}
#define size 10
void bubblesort(int *,const int );
int main()
{
int a[size]={8,4,5,7,4,5656,7842,641,47,12,7};
int i;
printf("date items in original order\n");
for(i=0;i<size;i++)
printf("%4d",a[i]);
bubblesort(a,size);
printf("\nData items in ascending order\n");
for(i=0;i<size;i++)
printf("%4d",a[i]);
printf("\n");
return 0;
}
void bubblesort(int *array,const int size)
{
void swap(int *,int *);
int pass,j;
for (pass=0;pass<size-1;pass++)
for(j=0;j<size-1;j++)
if(array[j]>array[j+1])
swap(&array[j],&array[j+1]);
}
void swap(int *element1Ptr,int *element2Ptr)
{
int hold=*element1Ptr;
*element1Ptr=*element2Ptr;
*element2Ptr=hold;
}