Consider a right angled triangle ABC, right angled at B. Now let AB be the tree (AB = 18m) and BC be its shadow. Refer the attachment.
Now according to the question, we have <C = 45 (as angle of elevation of sun is 45 degrees)
Thus we have tan45 = AB/BC
or, 18/BC = 1
or, BC = 18m
Now as BC = 18m, length of shadow = 18 metres.
Hope that helps !!