Let us consider a triangle where AB to be the flagstaff of 10 m and BC to be of 20 m as the distance between the tower and the flag.
Considering ABC and ADE as triangle
AB = 10 = CE
BC = 20 = AE
Calculating the values of ABC
tan x = AB/BC
tan x = 10/20
10/tan x = 20..............(1)
Calculating the values of ADE
tan(90-x) = DE/AE
cot x = DE/20
DE/cot x = 20 .............(2)
Solving equations 1 & 2
10/tan x = DE/cot x
DE = 40
Hence the total height of the tower is DE+CE = 40+10= 50 m.