Although all the answers are generally correct, in my opinion. Namely, it would be optimized, and it would depend on machine code, etc. I think that in the simplest case, without assuming any optimization and non-speculative branching (which may be unrealistic), Code 1 will be faster, because this is a certain amount of overhead when setting up loops. Namely, you must declare the variables I and J. Since the overhead of the outer loop always happens only once, the inner loop is a real factor here. Since in code 1 the inner loop is configured only 100 times, and in code 2 the inner loop is set 1000 times, code 1 should be faster. Again, this is in the simplest case, which is probably due to an interview question or a quiz question.
Mutmansky
source share