I notice that you have three global variables:

int array[50];
int highestValue = array[0];
int lowestValue = array[0];
array should be local to the main function, then passed around as needed....