I tested it, and yes, the error occurs when the number you mentioned is too large. It is not a problem with your program. What you designed is to use %d, which is an integer variable. The maximum value of an integer variable is How much? If it is larger, it will cross the boundary and the display will be wrong.
I am using Vc6. The maximum integer is ten digits. If it is larger, there is nothing you can do. That is to say, as long as the number you output It's right if you don't cross the line