In a scenario where you wanted your program to work on almost any PC with an OS no older than Windows 2000, how many times would you likely need to compile your code?
If you mean "how many times I need to compile while developing".... it is impossible to know (do a piece a code - compile and test - do another piece etc).
If you mean how many executables you will need to create for various windows versions and if you would need to change code (or part of code) in order to allow program to truely run in all those versions, the question is hard to explain in an absolute way.
THe problem is that windows don't care to retro-compatibily (even if in newer versions you see "run in a compatible mode", that compatible mode most of times don't work at all).
First problem: find libraries and compilers that produces exe-modules compatible with also an old windows (probably it is simply, but I don't know).
So... check if you need to change library version (for example) and if you need to change part of code
Second problem: use a 32-bit machine (64-bit is recent) becouse you probably will be able to run a 32-bit exe under a 64-bit Windows, but surely you cannot do the opposite. So if your machine is 64-bit and you try to compile for windows 98 you must check how to create a 32-bit exe (and compatible with windows 98)
for as long as my compiler doesn't give me errors. For easy errors to fix (syntax errors/semantic errors) the compiler will tell you and scroll to the line each time you compile (for a small project). For logic errors its a bit harder but then you use a debugger.