I am using a Sony W520 camera. The specifications mention Focal Length (f= mm) 4.5-22.5. What number should I take? The lower value or the higher? And if not both of them, then how to calculate actual focal length without knowing distance?
This is a zoom camera - the lens move and changes focal length - it can be 4.5mm, it can be 22.5mm and it can be any value in between.
When the camera is most zoomed out it's 4.5mm and when it's most zoomed in it's 22.5mm (and when its somewhere in the middle its somewhere in the middle).
This is not response to your question, but it is response to question you should have asked.
First of, these numbers indicate that your camera has 5x zoom (22.5 / 4.5 = 5). Second, considering that size of your camera sensor is roughly 6.2x4.65mm these numbers mean that lens of an analog 35mm film camera (or full frame digital) that gives same range is ~25-125mm.
Focal length of 50mm gives "normal" FOV approximate to what you see with your eyes, so finally, numbers from your camera mean that it goes from half of normal FOV (think of it as 2x zoomed-out) to 2.5x normal when fully zoomed in.
First, I assume by your question that what you want is to have the correct focal length so that all of what you are shooting in the picture. Please correct me if this is not what you wanted.
As Nir said, this is a zoom camera - and honestly, the focal length cannot be calculated by the distance of the camera from the subject (at least I don't know such a way).
I would follow these steps -
Choose a comfortable location to stand/sit, point the camera at the what you want to shoot, zoom out completely, and see if you have everything you want in the frame. If you don't have all of what you want to shoot (that is, some of it is partially or totally outside the frame), think about moving further from your subject. If there is not much space, consider changing your photo shoot location to a different place where you have the distance between you and your subject to fit in all of your subject.
If, on the other hand, you have more than what you need that you see in the frame, zoom in a little bit, check if you have everything in the frame. Repeat until necessary.
Hope that helps.
Edit: If you still want to know the focal length after you found the best focusing distance, you can either look at the live view screen - switch between your display modes (I am not sure how that works on on your camera), OR you can find the info as below once you import the photo onto a computer -