I'm trying to prove that the center of a group is a subgroup, and so far I've managed to prove that $Z(G)$ is not empty and closure. I've also come up with a proof that the inverse element exists however I'm not sure if it's correct:
Let $r\in Z(G)$. Then, it follows that $r\in G$ and hence there exists $r^{-1}\in G$ such that
$rr^{-1}=r^{-1}r=e$(the identity element)
Let $g\in G$, then from:
$\begin{aligned} gr&=rg \qquad \qquad /\cdot r^{-1}\\ r^{-1}\cdot/\qquad \qquad g&=rgr^{-1}\\ r^{-1}g&=gr^{-1}\implies r^{-1}\in Z(G) \end{aligned}$