I think if we try to be tight, the answer is 
sqrt(r^2 +l^2/4)

(l is the total height of the cylinder)