The top of a hill observed from the top and bottom of a building of height $h$ is at angles of elevation $p$ and $q$ respectively.
The height of the hill is:
Let height of hill be $H$ and horizontal distance be $x$.
From bottom of building:
$\tan q = \dfrac{H}{x}$
From top of building:
$\tan p = \dfrac{H-h}{x}$
Subtracting:
$x(\tan q - \tan p)=h$
So,
$H = \dfrac{h\tan q}{\tan q-\tan p}
= \dfrac{h\cot p}{\cot p-\cot q}$