Q) Say the commutative Ring with identity $C(\Bbb R)$:
$$(C(\Bbb R),+,\bullet) = \left\{f : \mathbb{R} \to \mathbb{R} \mid f \ \text{is continuous}\right\},$$
for the real number set $\Bbb R$.
For instance: $$f(x) = \operatorname{sin}(x)$, \quad g(x) = \operatorname{cos}(x),$$
then, $$(f+g)(x) = \operatorname{sin}x + \operatorname{cos}(x), \quad (fg)(x)= \operatorname{sin}(x)\operatorname{cos}(x).$$
Let $$I = \left\{f \in C( \Bbb R) \mid \exists M >0 : \vert x \vert >M \Rightarrow f(x)=0 \right\}.$$
There is a someone who said:
$I$ is an ideal of $C(\Bbb R).$
I can't understand why does this is an ideal of $C(\Bbb R)$, since by ideal test, taking the counterexample:
$$f= {1 \over x^2 + 1} \in I, \quad \text{and} \quad g = x^2 +1 \in C(\Bbb R). $$
So, who is correct?
Your counterexample would work if $f \in I$. But $f$ is not in $I$. It is continuous, but there is no $M$ so that if $|x|>M$ that $\dfrac{1}{x^2+1}=0$. In fact, $\dfrac{1}{x^2+1}$ is never $0$ on $\mathbb{R}$!
Think about what the set $I$ means. The definition of $I$ is that it is the set of $f \in C(\mathbb{R})$, so $f$ is a continuous function, such that there is an $M$ that when $|x|>M$, $f(x)=0$. What does this last part mean? Well, $|x|>M$ implies $x< -M$ and $x>M$. The condition then says that there must be a point such that when you move far enough to the left/right of the origin, $f(x)$ is $0$, i.e. $f(x)$ is eventually $0$.
Let's see why this this is an ideal. Let $f,g \in I$ and $r \in \mathbb{R}$. Now $f,g \in I$ means there is a point where $f$ and $g$ are $0$. Let's say $f$ is zero when $|x|>N$ and $g(x)$ is $0$ when $|x|>M$.
$rf \in I$: If $|x|>N$, then $f(x) \equiv 0$ so that $rf(x) \equiv 0$. But then the same $N$ works for $rf$ as for $f$. Then $rf \in I$.
$f+g \in I$: Let $A= \max\{N,M\}$. Then if $|x|>A$, then $f(x) \equiv 0$ because $|x|>A\geq N$ and $g(x) \equiv 0$ because $|x|>A \geq M$. But then for $|x|>A$, then $f(x)+g(x) \equiv 0+0=0$. But then $f+g \in I$.
Then $I$ is an ideal of $C(\mathbb{R})$.