If $f$ has a local maximum or local minimum at $x=c$, and is differentiable at this same point, then $f'(c) = 0$.
Proof:
Suppose that $f$ has a local maximum at $x=c$. Thus, $f(c) \ge f(x)$ for all $x$ sufficiently close to $c$. Equivalently, if $h$ is sufficiently close to $0$, with $h$ being positive or negative, we have
$$f(c) \ge f(c+h)$$Notice that the above includes two of the terms found in the limit definition of the derivative. Consider what happens when we try to build up the rest of this limit. First, let us get these two terms next to one another by subtracting $f(c)$ from both sides
$$0 \ge f(c+h) - f(c)$$We can divide both sides by $h$ to create the desired difference quotient, but we must be careful -- when we divide inequalities by a negative, the inequality symbol is reversed. When we divide by a positive value, the inequality symbol stays the same. As such, let us break things into two cases:
If $h > 0$, we can leave the direction of the inequality unchanged. Thus, $$ 0 \ge \frac{ f(c+h) - f(c) }{h} $$ Given this, one can see that the following limit can't possibly be positive. $$ 0 \ge \lim_{ h \rightarrow 0^+ } \frac{ f(c+h) - f(c) }{h}$$ Alternatively, if $h < 0$, we must reverse the direction of the inequality, yielding $$ 0 \le \frac{ f(c+h) - f(c) }{h} $$ So if we take the limit of the same expression from the other side, the result can't possibly be negative. $$ 0 \le \lim_{h \rightarrow 0^- } \frac{ f(c+h) - f(c) }{h}$$ Recall, both of these limits must exist and agree in value with $f'(c)$, as we assumed $f$ is differentiable at $x=c$.
Thus, $f'(c) \ge 0$ and $f'(c) \le 0$, which of course means that $f'(c) = 0$.
QED.