to show $X$ is disconnected I was asked in the exam to show $X=\{(p_1,\dots,p_n):p_i\in\mathbb{Q}\}$ is disconnected.
But  is this  a valid question as they did not mentioned  any mother space, anyway I assumed they asked me to show that $X$ is disconnected in $\mathbb{R}^n$
$\mathbb{Q}$ is disconnected in $\mathbb{R}$, here is one disconnection $$A_1=(-\infty,\sqrt{2})\cap \mathbb{Q}, A_2=(\sqrt{2},\infty)\cap\mathbb{Q}$$ 
Should I take $A_1\times A_2\dots\times A_n$ for showing disconnection of $X$ in $\mathbb{R}^n$?
Thank you for discussion and help.
 A: The quickest route is probably to note that projection onto the first coordinate is a continuous surjection onto the rationals. Thereby the space cannot be connected because it has a disconnected continuous image. 
A: Hint: for $n=2$ take $A_1\times \Bbb Q$ and $A_2\times\Bbb Q$. 
Clearly, $X$ can be endowed with a discrete topology (which is often natural for countable spaces), but the disconnectedness is of course trivial. That's why I guess you're right assuming the inherited topology of $\Bbb R^n$
A: You can try to use the following useful:
Claim: A topological space $\,X\,$ is disconnected iff there exists a continuous surjective function $\,X\to\{0\,,\,1\}\,$ , where $\,\{0\,,\,1\}\subset\Bbb R\,$  gets the inherited euclidean topology (and, thus, it is a discrete space)
Well, in your case you could try
$$f:X\to\{0,1\}\;,\;\;f(p_1,\ldots,p_n):=\begin{cases}0& ,\;\;\;p_1\in A_1:=(-\infty\,,\,\sqrt 2)\cap\Bbb Q\\{}\\1& , \;\;\;p_1\in A_2:=(\sqrt 2\,,\,\infty)\cap\Bbb Q\end{cases}$$
Assuming, of course, the topology on $\,X\,$ is the inherited one from the euclidean one in $\,\Bbb R^n\,$
== For all those who did read this answer before and the comments below: I was wrong, Stefan was right and the answer now's corrected.
A: HINT,we conisider $n=2$. $ A=(-\infty,\sqrt2)\times (-\infty,\sqrt2)\cap\mathbb{Q}\times\mathbb {Q}$ $=$$ (-\infty,\sqrt2]\times (-\infty,\sqrt2]\cap\mathbb{Q}\times\mathbb {Q}$, from this we can say $A$ is clopen set.
