While all the answers are generally correct, in my opinion. Namely, it would be optimized out and it would depend on the machine code, etc. I think in the most simplistic case, assuming no optimization and no speculative branching (which may not be realistic), Code 1 would prove to be faster because there is some amount of overhead in setting up the loops. Namely, you have to declare the i and J variables. Since the outer loop's overhead always only happens once, the inner loop is the real factor here. Since in Code 1, the inner loop is only set up 100 times and in the Code 2, the inner loop is set up 1000 times, Code 1 should be faster. Again, this is in the most simple case, which is probably what the interview question or quiz question was fishing for.