i have two logics for selection sortind...pointer p is for arrays base address.

1st logic:

Code:

void selectionSort(int *p)
{
int i,j,temp;
for(i=0;i<24;i++)
{
for(j=1;j<25;j++)
{
if(*(p+i)>*(p+i+j))
{
temp=*(p+i);
*(p+i)=*(p+i+j);
*(P+i+j)=temp;
}
}
}
}

2nd logic:

Code:

void selectionSort(int *p)
{
int i,j,temp;
for(i=0;i<24;i++)
{
for(j=i+1;j<25;j++)
{
if(*(p+i)>*(p+j))
{
temp=*(p+i);
*(p+i)=*(p+j);
*(P+j)=temp;
}
}
}
}

My question is---logic 1 is not working correctly...i am not able to find out any error.....if anybody?????plzzz explain the fault