First of all, it's nice to describe what your problem is.
Second, it's also nice to explain what your program is supposed to do. In this instance, explain the definition of what you mean by "magic number".
I've found a problem in rnum() where you can easily end up in an infinite loop:
I think what you wanted to write was:
number /= 10; // i.e. number = number / 10;
Now your code runs, not ending up in an infinite loop.