From the Figure :
The Height of from Ledge to the Straight line where is Bird is Flying is :
⇒ (40 ft - 8 ft) = 32 ft
We know that :

Here Opposite Side is Height of the Ledge from the Straight line where the Bird is Flying
Hypotenuse is The Distance Bird should fly in order to Land on the Ledge


