We know the adjacent side to the angle = 40
And we are looking for the opposite side to the angle = tree height
The trig function that relates the opposite / adjacent = tangent
So
tan ( 50°) = opp / 40 multiply both by 40
40 tan (50°) = opp = tree height ≈ 47.7 ft