Prove that $\displaystyle A \overset f \longrightarrow B \overset h \longrightarrow C \overset g \longrightarrow D$ is exact iff $f$ is surjective and $g$ injective، where h= 0
I know that it is exact if $\operatorname{im}f=\ker h$ and $\operatorname{im} h = \ker g,$ but I can't prove $f$ is surjective and $g$ injective.
A counterexample for the right-to-left direction is given by $A=B=C=\mathbb{Z}$ and $f = g = \operatorname{id}$ and $h$ is the doubling map $h(n) = 2n$. Both $f$ and $g$ are injective and surjective, but the sequence is not exact because, for instance, $\ker h = 0$ but $\operatorname{im} f = B = \mathbb{Z}$.
A counterexample for the other direction is given by $f(n) = 0$, $h = \operatorname{id}$, $g(n) = 0$, where $f$ is not injective, but the sequence is exact. (You can make a similar example where the sequence is exact but $g$ is not injective).