I was solving the following question (in fig), with the hint that if $n \neq 1 \pmod q$ then there exist a character $\phi$ mod q such that $\phi(n) \neq 1$.
Show that $$ \sum_{\chi\pmod q}\chi(n) = \begin{cases} \varphi(q) &\text{if } n \equiv 1 \pmod q \\ 0 &\text{otherwise}. \end{cases} $$
I am not sure how the hint is true. But my logic for the hint is following -: $(\mathbb{Z}/q\mathbb{Z})^*$ is isomorphic to direct product $\mathbb{Z}/2\mathbb{Z} \times \mathbb{Z}/2^{\alpha_2-2}\mathbb{Z} \times \mathbb{Z}/p_{2}^{\alpha_2}\mathbb{Z}^* \cdots \times \mathbb{Z}/p_{k}^{\alpha_k}\mathbb{Z}^*$.
Where $q = 2^{\alpha_1}p_1^{\alpha_2} \cdots p_k^{\alpha_k}$. So each of the RHS is a direct product of cyclic groups hence every character of our original group is determined by these characters of these $k+1$ groups of RHS.
So if $n \neq 1 \pmod q$ the, if we see its image on RHS at least one component of RHS will be not identity and we can map that to an element not equal to $1$.
Is my reasoning correct?

Yes. I think the most elementary way is to show that for any finite abelian group $G=\langle H,a\rangle$ then any character on $H$ extends to some character on $G$.
Proof: let the least $k\ge 1$ such that $a^k\in H$, and take $\psi_G(a)$ such that $\psi_G(a)^k = \psi_H(a^k)$.
Starting with $H$ the cyclic subgroup of $\Bbb{Z/(q)}^\times$ generated by $n$ and some obvious non-trivial character we can extend it to a character on $\Bbb{Z/(q)}^\times$ such that $\psi(n)\ne 1$, from which $(\psi(n)-1)\sum_{\chi\bmod q}\chi(n)=0\implies \sum_{\chi\bmod q}\chi(n)=0$.