Let $f : \Bbb{R}\to \Bbb{R}$ be a function such that
(a) $f(x + y) = f(x) + f(y)$ for all real numbers $x, y$
(b) $f(xy) = f(x) f(y)$, for all real numbers $ x, y$
MY SOLUTION
For $k \in \Bbb{Z}$ it's easy to show $f(kx)=kf(x)$.
Let $y$ be any real and $y=a+b$ where $a\in \Bbb{Z}$.
$f(xy)=f(ax)+f(bx)=af(x)+f(b)f(x)=f(x)f(y)$
From here we get a solution $f(x)=0$ or we get $a+f(b)=f(y) \Rightarrow y-b+f(b)=f(y) \Rightarrow f(b)-b=f(y)-y=c(say)$
So we get $f(x)=x+c$. Putting it in original equation, we get $c=0\Rightarrow f(x)=x$.
Hence we get $2$ solutions $f(x)=0$ & $f(x)=x$.
Is this a correct solution? Or am I losing generality is some step ?
As the comment says, you have just shown that $f(x)-x=f(y)-y$ when $\{x\}=\{y\} \Big(\{x\}=x-[x]\Big)$.
This is the general proof of $f(x)+f(y)=f(x+y)$ and $f(x)f(y)=f(xy)$.
\begin{align} & \text{let } \begin{cases} P(x, y): f(x)+f(y)=f(x+y). \\ Q(x, y): f(x)f(y)=f(xy). \end{cases} \\ \ \\ P(0, 0): \; & f(0)+f(0)=f(0), f(0)=0. \\ P(x, 1): \; & f(x)f(1)=f(x). \\ \text{if } \; & \color{blue}{f(x) \equiv 0}: \text{Solution.} \\ \text{if } \; & \exists x \text{ s.t. } f(x) \neq 0: f(1)=1. \\ \ \\ & \text{For } n \in \Bbb{N}: \\ \ \\ P(1, n-1): \; & f(n-1)+1=f(n). \\ P(1, n-2): \; & f(n-2)+1=f(n-1). \\ & \vdots \qquad \vdots \qquad \vdots \\ P(1, 1): \; & f(1)+1=f(2). \\ & 1=f(1). \\ \therefore \; & f(n)=\underbrace{1+1+\cdots+1}_{n \text{ times}} = n. \\ \ \\ P(n, -n): \; & f(n)+f(-n)=f(0)=0, f(-n)=-n. \\ \therefore \; & \text{For } p \in \Bbb{Z}, f(p)=p. \\ \ \\ & \text{For } p, q \in \Bbb{Z}: \\ \ \\ Q\left(p, \frac q p\right): \; & pf\left( \frac q p \right) = q, f\left(\frac q p \right) = \frac q p. \\ \therefore \; & \text{For } r \in \Bbb{Q}, f(r)=r. \\ \ \\ Q(x, x): \; & f(x)^2=f(x^2). \\ \therefore \; & x \geq 0 \Rightarrow f(x) \geq 0. \\ \ \\ & \text{For } x \geq y ( x-y \geq 0): \\ P(x-y, y): \; & f(x-y)+f(y)=f(x), f(x-y) \geq 0. \\ \therefore \; & f(x) \geq f(y). \\ \Rightarrow \; & f: \text{ monotonically increasing function.} \\ \ \\ & \text{For } x \in \Bbb{R} \setminus \Bbb{Q}: \\ & \text{Assume that } f(x) > x. \\ \Rightarrow \; & \exists r \in \Bbb{Q} \text{ s.t. } f(x)>r>x. \\ \Rightarrow \; & r>x, f(r) \geq f(x), f(r) \geq f(x) > r, f(r)>r. \\ \Rightarrow \; & \text{Contradiction.} \\ \ \\ & \text{Assume that } f(x) < x. \\ \Rightarrow \; & \exists r \in \Bbb{Q} \text{ s.t. } f(x)<r<x. \\ \Rightarrow \; & r<x, f(r) \leq f(x), f(r) \leq f(x) < r, f(r)<r. \\ \Rightarrow \; & \text{Contradiction.} \\ \ \\ \therefore \; & \color{blue}{f(x)=x} \text{ for } \forall x \in \Bbb{R}. \\ \ \\ \therefore \; & \boxed{\color{blue}{f \equiv 0, f(x)=x}}. \blacksquare \end{align}