Which is better for performance? This may not be consistent with other programming languages, so if they are different, or if you can answer my question with your knowledge in a
Your question as you give it is ill posed. The IO that you have inside the loops dominates all that the loop handling statements ever could add by at least one order of magnitude. My bet would even be that you can't measure any significant difference since it would not be distinguishable from the noise (in terms of measurement) that the IO produces.
The thing would only matter, if the code inside the loop would be really fast. Here fast meaning not even to have a memory read instruction, since then already CPU memory bandwidth would dominate, again.
So if you are really curious, and you seem to be, read the assembler and look at the code. If you only have two small functions with just each type of loop, the output is not so difficult to read, really, don't be scared. I'd suggest to do it with C, though, this is probably closest to the assembly and easiest for you to identify the parts.
You didn't tell us on what system/compiler you are. With gcc the options would be -S -O3 -march=native
to have it produce a .s
file.