is the statement correct to generate a 5 digit number? |
The easiest way to get a particular distribution of pseudo-random numbers is to use the C++ <random> library. It has been a part of the C++ standard since the adoption of C++11.
http://www.cplusplus.com/reference/random/
The C++ <random> library is very robust, offering a wide variety of ways to generate random numbers, unlike C's <stdlib.h> srand/rand functions.
The C Standard recommends not using the functions if alternatives are available. C++ has that.
A working paper on Random Number Generation in C++11 in PDF form:
http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2013/n3551.pdf
It has some brief examples how to use the library. There are also examples here at the CPlusPlus reference pages, as well as examples at cppreference:
https://en.cppreference.com/w/cpp/numeric/random
The working paper also a proposal for adding a simple toolkit to the library. I slightly adapted it for my personal use, adding it to a project whenever I need random number when creating programs in C++ or Win32 API.
I can provide the code of my toolkit version and examples how to use if you want.