Verification of Proof that a nonabelian group G of order pq where p and q are primes has a trivial center

I think the correct hint is:

If $G/Z(G)$ is cyclic then $G$ is abelian.

$Z(G) \subseteq G$ and so we can have $$|Z(G)| = 1, \ p , \ q , \ pq $$ $G$ is nonabelian and so $|Z(G)| \neq pq $.

If $|Z(G)| = p $ or $|Z(G)| = q $ the quotient group $G/Z(G)$ has prime order, whence is cyclic and by the hint $G$ is abelian.

Thus $|Z(G)| = 1$


Your result can be proved directly:

Suppose $Z(G) \neq \{1 \}$. Because $G$ is not abelian, $Z(G)$ has order $p$ or $q$; say $|Z(G)|=p$. In particular, there exists $x \in Z(G)$ of order $p$. Let also $y \in G$ of order $q$. Now, it is easy to notice that the set $$X= \{ x^m y^n \mid 1 \leq m \leq p, \ 1 \leq n \leq q \}$$ has cardinality $pq$, hence $G=X$. Now, because $x \in Z(G)$, we clearly deduce that $G$ is abelian: a contradiction.