Solution to Abstract Algebra by Dummit & Foote 3rd edition Chapter 7.1 Exercise 7.1.9
Let $R$ be a ring. For a fixed element $a \in R$, define $C_R(a) = \{r \in R \ |\ ra = ar \}$. Prove that $C_R(a)$ is a subring of $R$ containing $a$. Prove that $$Z(R) = \bigcap_{a \in R} C_R(a).$$
Solution: (We do not need to assume that $R$ has a $1$.)
Note that $aa = aa$, so that $a \in C_R(a)$. Similarly, $0a = a0$, so $0 \in C_R(a)$. If $R$ has a $1$, then since $1a = a1$, $1 \in C_R(a)$.
Now if $x,y \in C_R(a)$, then $$(x-y)a = xa-ya = ax-ay = a(x-y),$$ so that $x-y \in C_R(a)$, and $xya = xay = axy$, so that $xy \in C_R(a)$. Thus $C_R(a)$ is a subring.
If $x \in Z(R)$, then for all $r \in R$, $xr = rx$. Thus for all $r \in R$, $x \in C_R(r)$, and we have $x \in \bigcap_{r \in R} C_R(r)$.
Now if $x \in \bigcap_{r \in R} C_R(r)$, then for all $r \in R$, $x \in C_R(r)$. So $xr = rx$, and we have $x \in Z(R)$.