Prove that the rank of a block diagonal matrix equals the sum of the ranks of the matrices that are the main diagonal blocks. 
*

*If $A$ and $B$ are matrices, $0$ is a zero matrix, and \begin{equation*}
X=
\begin{pmatrix}
A& 0
\newline
0& B
\end{pmatrix},
\end{equation*}
prove that $\mathrm{rank}(X)=\mathrm{rank}(A)+\mathrm{rank}B)$.

*Also, if the upper right zero matrix would be replaced with matrix $C$, that is, 
\begin{equation*}
X=
\begin{pmatrix}
A& C
\newline
0& B
\end{pmatrix}
\end{equation*}
would it still be true that $\mathrm{rank}(X)=\mathrm{rank}(A)+\mathrm{rank}B)$?

By the matrix equivalent result, we can find two invertible matrices $P$ and $Q$ such that:
$$J_r=Q^{-1}AP,$$
where $J_r=\mathrm{diag}(1,\ldots,1,0,\ldots,0)$ with $r=\mathrm{rank}(A)$ ($r$ is the number of $1$).
Similary for $B$, there's $P'$ and $Q'$ such that:
$$J_{r'}=Q'^{-1}BP',$$
where $r'=\mathrm{rank}(B)$.
Now with the invertible block matrices $S=\mathrm{diag}(Q,Q')$ and $T=\mathrm{diag}(P,P')$ we have:
$$J=S^{-1}XT,$$
where $J=\mathrm{diag}(J_r,J_{r'})$ and it's clear that: 
$$\mathrm{rank}(X)=\mathrm{rank}(J)=\mathrm{rank}(J_r)+\mathrm{rank}(J_{r'})=\mathrm{rank}(A)+\mathrm{rank}(B).$$
