heres my source code i dont know what im doing wrong.. to reverse the elements of the array so that a[0]=a[5],and a[1]=a[4]and so on......
ex. a[]=8,9,13,3,2
it now should be..... a[]=2,3,13,9,8
my source code is below...help if u can...
# include <stdio.h>
# define MAX 6
void insertionsort (int list[],int first,int last);
int main (void)
{
int i;
int ary[MAX]={89,72,3,8,25,6};
printf("elements");
for (i=0;i<MAX;i++)
printf("%3d\n",ary[i]);
insertionsort (ary,i,MAX);
printf("elements reversed");
for (i=0;i<MAX;i++)
printf("%3d",ary[i]);
return 0;
}
void insertionsort (int list[],int first,int last)
{
int temp;
int end;
int mid;
mid=(first+last)/2;
for (first=0;first<=mid;first++)
for (end=last;end>mid;end--)
if((first+last)==MAX)
{
temp=list[first];
list[first]=list[last];
list[last]=temp;
}
return;
}