I am not sure whether I stated to title correctly, but here is the problem that came up while studying.
For a continuous function $f: \mathbb{R} \rightarrow \mathbb{R}$, find all functions $f$ such that if $x$ is a rational number, then $f(x)$ is also a rational number. Also, if $x$ is irrational, then $f(x)$ is also irrational.
I could think of $f(x)=ax+b, f(x)=1/x$. Could there be any other functions?
I haven't studied real analysis, so I think this may be out of my knowledge.