  Let $R$ be a commutative ring. When is a subgroup of $(R, +)$ an ideal of
$R$? We investigate this problem for the rings $\mathbb{Z}^{d}$ and
$\prod_{i=1}^{d} \mathbb{Z}_{n_{i}}$. For various subgroups of these rings we
obtain necessary and sufficient conditions under which the above question has
an affirmative answer. In the case of $\mathbb{Z} \times \mathbb{Z}$ and
$\mathbb{Z}_n \times \mathbb{Z}_m$, our results give, for any given subgroup of
these rings, a computable criterion for the problem under consideration. We
also compute the probability that a randomly chosen subgroup from $\mathbb{Z}_n
\times \mathbb{Z}_m$ is an ideal.
