As you probably learned in your high school physics class, throwing an object at a 45 degree angle will give you the maximum range. This assumes you are throwing it at ground level, however. If you are throwing it 10, 20 or 50 meters above the ground, 45 degrees will not give you the maximum range; the maximum range is a function of both height and speed.
Given an initial speed V m/sec and a starting height of h meters, calculate both the angle (in degrees) that will give you the longest range, and what that range is (in meters). Use g=9.81 m/sec^2. You can neglect air resistance, and assume that your starting height will always be positive. The angle is measured from the vertical, so an angle of 0 is straight up, 90 degrees is parallel to the ground, and 180 is straight down. Your angle should be between 0-180 degrees. Your values for both speed and angle should be correct to a tolerance of 1e-6.
For example, with an initial speed of 100 m/sec thrown at ground level (h=0), the maximum range for your projectile is approximately 1019.367 meters, and the angle is 45 degrees. If you have h=50 m with the same speed, it can travel a maximum of 1068.198 meters, but only if you throw it at 46.339 degrees.