Sonar sensor to arduino to servo

d storing the ranges sensed by the sensor into variables.

an array would be much simpler.
Post your code and we'll see what we can do.