Q:

How to print the correct number of digits contains in the double variable?

The Expected Output is:

The Value 123456789 contains 9 digits.

But the given output is: 

The Value 1.23457e+08 contains 332 digits

The Source:
#include <iostream>
using namespace std;
int main ()
{
  double number_1 = 123456789;
  double numberOfdigits = 1;
  double tmp = number_1;
    while (tmp /= 10)
      numberOfdigits ++;
        cout << "The Value " << number_1 << " contains " << numberOfdigits << " digits " << '\n';
}

A:

Don't use Double unless you don't need to calculate and get the exact results.
In your case you can just use int or const int as you wish.
#include <iostream>
using namespace std;
int main ()
{
  int const number_1 = 123456789;
  double numberOfdigits = 1;
  int tmp = number_1;
    while (tmp /= 10)
    numberOfdigits ++;
    cout << "The Value " << number_1 << " contains " << numberOfdigits << " digits " << '\n';
}

A:

The Expected Output is: The Value 123456789 contains 9 digits.
while (tmp /= 10)

Either the end condition is wrong, or your expected output is wrong. The first 9 values of tmp are1:
123456789.
12345678.9
1234567.89
123456.789
12345.6789
1234.56789
123.456789
12.3456789
1.23456789

What do you expect the next value to be? Why do you expect it to be zero, which would end the loop? The next value will be 0.123456789, which is not zero and therefore does not end the loop.
If the number was represented with infinite precision, then the loop would continue indefinitely because dividing a number to smaller fractions never reaches zero mathematically. However, due to limited precision of floating point arithmetic it cannot represent arbitrarily small values, and the result will at some point round to zero1.

1 Except for the value 123456789. the shown mathematically accurate value of tmp may not be exactly representable by the floating point format and thus the actually stored value may be something very close to, but not exactly the shown value.
Given that further operations are performed on the slightly inaccurate value, the error accumulates through the oprations and could in theory increase. In this case we divide the erroneus value, and therefore the previous error scales down as well, so it should not get out of hand in this case.

If you want to know the number of digits in an integer, then simplest solution is to not involve floating point in the first place.

