Answer:
Take a look of the image below, we can think on this problem as a problem of two triangle rectangles.
We can see that both triangles share the adjacent cathetus, then the height of the flagpole is just the difference between the opposite cathetus.
Remember the relation:
Tan(a) = (opposite cathetus)/(adjacent cathetus)
So, if we define H as the height of the cliff
X as the distance between the observer and the cliff
and h as the height of the flagopole
we can write:
tan(40°) = H/X
tan(45°) = (H + h)/X
Notice that we have two equations and 3 variables (we should have the same number of equations than variables) then here is missing information, and we can't get an exact solution for the height of the flagpole.
But we can write it in terms of the height of the cliff H, or in terms of the distance between the observer and the cliff.
We want to find the value of h.
If we take the quotient between both equations, we get:
Tan(45°)/Tan(40°) = (H + h)/H
1.192 = (H + h)/H
1.192*H = H + h
1.192*H - H = h
0.192*H = h
So the height of the flagpole is 0.192 times the height of the cliff.