detail in proof of the mean value theorem for integrals I am trying to prove the following result

If $f$ is a continuous function on a closed interval $[a,b]$, then
there exists a $c \in (a,b)$ such that,
$$f(c)=\frac{1}{b-a}\int_a^bf(x)\;\mathrm{d}x$$

I have worked out the following proof
Because $f$ is continuous on the interval, it reaches a minimum $m$, and a maximum $M$ so that we have
$$\begin{aligned} m&amp;\leq f(x)\leq M \\ m(b-a)\leq  &amp; \int_a^bf(x)\;\mathrm{d}x\leq M(b-a) \\  m\leq &amp;\frac{1}{b-a}\int_a^bf(x)\;\mathrm{d}x\leq M\end{aligned}$$
and the IVT guarantees the exxistence of $c$ as above.
How do I prove that $c \neq a\ \&amp; \ c\neq b$?
Thanks for the help !
Assume $w&lt;z, w,z\in [a,b]$ with $f(w) = m, f(z) = M$
If $m=M \implies f$ is a constant function then all $c\in(a,b)$ works.
Suppose $m&lt;M$
We have that for $c\in [w,z]$, $f(c) = \frac{1}{b-a}\int_{a}^{b}f(x)dx$
Suppose $c = a$, then $a = w$, because $a\leq w \leq c \leq  z \leq b$
Then $f(a) = m$ is the  minimum of the function
$f(z) =M&gt;m \implies$ there exist some $\delta &gt;0$ such that $f(x)&gt;m+\epsilon$ for some $\epsilon&gt;0$ for all $x\in (z-\delta,z]$
Thus we have that $\begin{aligned}\int_{a}^{b}f(x)dx &amp; = \underbrace{\int_{a}^{z-\delta}f(x)dx}_{\geq f(a)\cdot(z-\delta -a)} +\underbrace{\int_{z-\delta}^{z}f(x)dx}_{\geq (f(a) + \epsilon)\cdot\delta&gt;f(a)\cdot \delta}+\underbrace{\int_{z}^{b}f(x)dx}_{\geq f(a)\cdot(b-z)}&gt;f(a)\cdot(b-a)\\  &amp;\underbrace{\frac{1}{b-a}\int_{a}^{b}f(x)dx}_{f(c)} &gt; f(a)\end{aligned}$
that is a contradiction. Then $c \neq a$
I hope it help you,
I think the other cases will be analogous
(for example, apply this reasoning to $-f$)
Sometimes a figure is worth 1000 words:

What is the area in blue?
$$\int\limits_a^b f(x)\ dx$$
What is the area in orange?
$$f(c) \cdot (b-a)$$
QED.