How did the answer key get $h=40-2r$? 
A cone has radius of $20\ \rm cm$ and a height of $40\ \rm cm$.
  A cylinder fits inside the cone, as shown below.

What must the radius of the cylinder be to give the cylinder the maximum volume.
  You do not need to prove that the volume you have found is a maximum volume.
Show any derivatives that you need to find when solving this problem.

http://www.nzqa.govt.nz/nqfdocs/ncea-resource/exams/2014/91578-exm-2014.pdf p11 (e)

$$h=40-2r\\[5pt]\begin{align}V&=\pi r^2h\\&=\pi r^2(40-2r)\\&=40\pi r^2-2\pi r^3\end{align}\\[5pt]\frac{\mathrm dV}{\mathrm dr}=80\pi r-6\pi r^2\\\frac{\mathrm dV}{\mathrm dr}=0\implies80\pi r-6\pi r^2=0\\2\pi r(40-3r)=0\\r=\frac{40}3\text{ or }0\\r=\frac{40}3\ \mathrm{cm}$$

I was doing this calculus problem and I couldn't figure out how the answer key got $h=40-2r$. This had been bothering me for several days. Could someone please explain how the answer key got $40-2r$ for $h$?
 A: In the picture, you can see two cones, which I will call Big Cone and Little Cone. These two cones are similar.  Little Cone is a scaled down version of Big Cone.
Note that Big Cone has height $40$ and radius $20$. So the height of Big Cone is twice the radius of Big Cone.
By similarity, the height of Little Cone is twice the radius of Little Cone.
But the radius of Little Cone is $r$. So the height of Little Cone is $2r$. 
It follows that the height $h$ of the cylinder is $40-2r$ (height of Big Cone minus height of Little Cone).
A: If you want to express the height of your cone, you first see that if the you set r=0 the height must be 40, and of your set r=20, h=0. If your look how how it must be continuous, and linear, it's pretty clear that the height of the cone in terms of r, must be h= 40-2r.
A: The radius of the cylinder $r(h)$ is a function of height and it decreases linearly. At $h=0$ the radius is $20$, the same as the base of the cone, and at $h=40$ it is $0$ (technically, at the extremities it ceases to be a cylinder, but we can overlook this). This is enough information to determine $r(h) = 20 - \frac{h}{2}$; in particular $r(h)$ is invertible so we get$$h(r) = 40 - 2r$$
To see why it is linear, note that a cone is essentially a decreasing linear function with a positive $y$ intercept rotated about the $x$-axis (from $x=0$ to its $x$ intercept).
A: Notice, by similar triangles, that $\dfrac{40 cm}{20 cm} = \dfrac{h}{r}$ where $h$ is the altitude between the top of the cylinder to the apex of the cone. The constraint on the cylinder forces the height of the cylinder to be $40 - h = 40 - 2r$, which has nothing to do with area.
