strange behaviour by changing the variable declaration
this is the link to code .
i have marked the code with comments and printfs to directly get to the problem,
this is a code to sort an array on the basis of their frequency with input values 1 to 60.
I sorted the frequencies in the array B using quicksort, but when i return the pivot index from the partition function the value of my other variable A[60] is somehow getting equal to this index , and this is reflected in the printf statement , but when i instead declare the int variable pi to be local inside quicksort the problem is solved , but if it is global the problem persists !!
the test case for this behaviour is “”"""""""" : 1 as the no of test cases and 5 as the no of inputs and 5,5,4,6,4 being these numbers !!!
how can declaring a variable affect another variables value !!! either i know nothing about c or it is seriously strange !! any help would be appreciated !!!

The first error I see is that you are accessing outside the bounds of arrays A and B
You have

int A[60], B[60];
for (i=1; i<=60; i++)

A and B only have cells A[0], A[1], …, A[59].