Let OP be the tower of height h (say) and PQ the flag-staff of height a, such that
∠OAP = θ and ∠PAQ = ɸ
In ΔOAP and ∠OAQ
OA = OP cot θ = h cotθ
and OA = OQ cot ( θ + ɸ ) = (h + a) cot ( θ + ɸ )
∴ h cotθ = (h + a) cot ( θ + ɸ )
⇒ h = a cot ( θ + ɸ ) / cotθ - cot ( θ + ɸ )