Meaning of codes

Mar 16, 2014 at 10:39am
Void convert(intT[]; int Num)
{
int i,j, temp;
for(i=Num;i>0;i-=1)
{
J=i-1;
temp=p[i];
p[i]=p[j];
p[j]=temp;
}
}
Please explain each code
Mar 17, 2014 at 1:25am
in this why loop condition is 1-=1
Mar 17, 2014 at 2:06am
i -= 1 implies that it is decrementing, not incrementing. So it counts down from Num to 0.
Mar 17, 2014 at 5:00am
Thank you. meaning of j=i-1 ?

Is this complete code for swap
Mar 17, 2014 at 5:18am
Well, the meaning of j=i-1 is that j is... well, equal to one less than i. In context of the code, p[i] will always be in one spot ahead of p[j] in the array. Since i is never zero, this code will therefore take the element at location p[Num], and shuffle it to the front of the array. Yes, it is the complete code of the swap.
Topic archived. No new replies allowed.