I assume food and calories are parallel arrays meaning that food[x] has calories[x] calories and you want to keep the food matched with the correct calories and you are trying to alphabetize the food array. If that is the case then swap calories[x] and calories[x + 1} in the body if the same if. Likewise if you want to sort calories in ascending (or descending) order and you want to keep the food matched with the calorie value, then swap them in the body of the same if statement.
In your code what happens when i = 0 and c = x - i? Is c + 1 a valid index?
Thanks for your help.