Provide examples or explain why it is impossible a) A continuous function defined on an open interval with range equal to a closed interval.
My example: $f(x)=\frac{1}{2}\sin(4\pi x)+\frac{1}{2}$ on $(0,1)$ to $[0,1]$.
Note: I am not considering $\mathbb{R}$ an interval.
b) A continuous function defined on a closed interval with range equal to an open interval. 
I think this is impossible if we exclude $\mathbb{R}$. Edit: we must also exclude unbounded intervals. By the Extreme Value Theorem, any  continuous function on a compact set attains a maximum and a minimum. Yet, the set of the points in an open interval doesn't include its supremum and infimum, a contradiction.
c) A continuous function defined on an open interval with range equal to an unbounded closed set different from $\mathbb{R}$.
My example: $f(x)=\sqrt{|x|}$ on $\mathbb{R}$ to [0,$\infty$). Is there another function that works and has a different domain than $\mathbb{R}$?
d) A continuous defined on all of $\mathbb{R}$ with range equal to $\mathbb{Q}$.
I was thinking maybe map the natural numbers to $\mathbb{Q}$ and use the rest to "fill in the gaps." Evidently, I need most help with d).
Thanks in advance!
 A: For a) I would just consider a constant function, $[a,a]$ is a closed interval. If you want an interval of positive length, $\sin$ or some variation (like yours) is the way to go. Personally I would prefer to adapt the domain to adding stuff and factors.
For b) your argument is correct for bounded intervals.
For c) you could do something with $x+\frac{1}{x}$.
For d) consider what the intermediate value theorem would mean for such a function.
A: For b) think about $(\sin x)(1-1/x)$ on $[1,\infty).$
A: This looks like mostly good work.
a) This is perfect as is.
b) Just excluding $\mathbb{R}$ is not enough since you can map $[0,\infty)$ to an open interval. But your argument is valid for bounded intervals.
c) If you want to find a map on a finite interval consider the map $(0,1)\to\mathbb{R}$ defined by $x\mapsto \frac{1}{x}$. This doesn't completely work yet but you can extend this function to $(0,2)$ in a way to make it work.
d) Take a look at the Intermediate value theorem
A: c) $f(x)  = |\tan x |$ from $(-\pi/2, \pi/2) \to [0,\infty)$
d) $f(x) = 1$ would map $x\in R$ to a subset of $\mathbb Q$ and that is the best you are going to be able to do.
For all of these, there is a definition definitions of continuous that you might find useful.
$f:X\to Y$ is continuous iff for every open sub-set $V\subset Y$ the pre-image of $V$ is open.
The pre-image of $V$ is  $f^{-1}(V) = \{x\in X|f(x)\in V \}$. 
