Showing that $g(x) = \begin{cases} f(x), & \ x \ne 0 \\ c, & \ x = 0 \end{cases}$ is Riemann integrable where $f$ is Riemann integrable Suppose that $f: [-1,1] \to R$ Riemann integrable and let $g:[-1,1]\to R$ be defined
by $g(x) = \begin{cases} f(x),  & \ x \ne 0 \\ c, & \ x = 0 \end{cases}$
Show that $g$ is integrable.
Attempt. 
Since $f$ is integrable, it follows that $\forall \epsilon >0$, $\exists$ some partition $p \in P_{[-1,1]}$ such that $U(f,p) - L(f,p) < \epsilon$. Now, suppose there is at least one $x_i \in p$ such that $\sup_{x \in[x_{i-1}, x_{i}]} g(x) = c$. Then, it follows that $g(0) = c \ge f(0)$. Hence, we have that
$$U(g,p) \le U(f,p) + 2c \implies U(g,p) - L(g,p) \le U(f,p) - L(f,p) + 2c < \epsilon + 2c = \epsilon_{g}.$$
Now, suppose there is some $x_{i} \in p$ such that $\inf_{x\in [x_{i-1}, x_{i}]} g(x) = c$. Hence $g(0) = c < f(0)$. So, we have that $L(g,p) < L(f,p)$, which means that
$$U(g,p) - L(g,p) - 2f(0) < U(f,p) - L(f,p) < \epsilon.$$
If there is no $x_{i} \in p$ such that $\sup_{x \in[x_{i-1}, x_{i}]} g(x) = c$ or $\inf_{x\in [x_{i-1}, x_{i}]} g(x) = c$ then it follows that
$$U(g, p) - L(g,p) = U(f,p) - L(f,p) < \epsilon.$$

hint
You just need to prove that $f-g $ is integrable.
put $d=|f (0)-c|$,
For a given $\epsilon>0,$ take the partition $$p=\{-1,-\frac {\epsilon}{4d},\frac {\epsilon}{4d},1\} $$
then
$$U (f-g,p)-L (f-g,p)=d\frac {\epsilon}{2d}<\epsilon.$$
