This should be very simple - and quite useful - for the voltage reading just
int reading = analogRead(PinNumber);
double result = doubleMap(reading,0,1024,0,5);
with this function to do the doubleMap since the map function is just for integers
double doubleMap(double x, double in_min, double in_max, double out_min, double out_max)
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}