This may be a stupid question, but how does the efficiency of a while loop compare to that of a for loop? I\'ve always been taught that if you can use a for loop,
That depends on the exact compiler that you use. In your example, a good compiler will create the same machine code for both options.