You just have to determine whether a number ends with 3, 6 or 9. Here is an example:
1 2 3 4 5 6
// MIN and MAX are two constant int variables signifying the range of numbers
// between which to search for the number of occurrences of 3, 6, and 9 respectively.
for (int i{ MIN }; i <= MAX; ++i)
{
i % 10 == 2 || i % 10 == 3 || i % 10 == 9 ? ++count : count += 0;
}