Let g(x) = 0 for all x and let f(x) = 0 when x is rational, f(x) = 1 when x is irrational. Clearly, f is not continuous.
On the other hand, if both f and g are continuous and f(x) = g(x) for all rational x, then f(x) = g(x) everywhere.
If is continuous and is such that f(x)=g(x) for all rational numbers x, is f continuos?
I'm not 100% sure about this because f is clearly continuos on the rationals, but what happens at the irrationals?
EDIT: Being slow today... consider g(x) = 1 (hence cts) and f(x) = 1 for x in Q, and 0 for x in R\Q. f(x) is discontinuous everywhere.
An even more interesting scenario on the properties f(x) can have is the following :
Let g(x) = sin(x) which is continuous over R
Let f(x) = g(x) for x rational (f agrees with g at rationals)
= -g(x) for x irrational (reflection of graph of g along the X axis at irrational x values)
It is easy to prove that f(x) is continouus only at the points K*pi, K belonging to Integers
and discontinuous everywhere ! Similarly, we can construct counter-intuitive functions continuous, say at Integers and
discontinuous elsewhere ! The old classic ,Hobson's "Theory of Functions-I,II" would be an illuminating read !!!!