void swap(int *a,int *b);
main()
{
int ar[5],i,j,n;
ar[0]=7;ar[1]=3;ar[2]=9;ar[3]=2;ar[4]=11;
printf("Array before sort:\n\n");
for(i=0;i<5;i++)
printf("ar[%d]=%d\n",i,ar[i]);
n=5; /*numberof items in sort array*/
for(i=0;i
if(ar[j]>ar[j+1])
swap(&ar[j],&ar[j+1]);
}
printf("Array after sort:\n\n");
for(i=0;i<5;i++)
printf("ar[%d]=%d\n",i,ar[i]);
system("pause");
return 0;
}
void swap(int *a,int *b)
{
int temp;
temp=*a;
*a=*b;
*b=temp;
}
No comments:
Post a Comment