Let r and h be the radius and height of the cylinder respectively.
Then, the surface area of the cylinder is given by
S=2πr2+2πrh
h=S−2πr22πr
=S2π(1r)−r
Let V be the volume of the cylinder. Then,
V=πr2h=πr2[S2π(1r)−r]=Sr2−πr3
Then, dVdr=S2−3πr2
d2Vdr2=−6πr
Now, dVdr=0⟹S2=3πr2⟹r2=S6π
When, r2=S6π,d2Vdr2<0
Therefore, by second derivative test, the volume is maximum when r2=S6π.
Now, when r2=S6π,h=2r.
Hence, the volume is the maximum when the height is twice the radius, i.e., when height is equal to the diameter.