Can somebody explain this?
int main() { int f=1, i = 2; while(++i<5) f*=i; cout << f; } (output is 12) If there is a nice soul out there whom would like to explain this as thoroughly as possible for me, it would be really appreciated. No matter how hard I try, I can't seem to get my head around it :S Espcially the while(++i<5) part. I don't understand the ++i<5 and how the output multiplied with f turns it into 12? as far as I understood this "int i" gets added up to 4(because can't go higher than 5), and then you multiply this with f which is 1*4??? or 2*4?? either way it doesn't make any sense that it turns into 12. :( As mentioned above, a thorough explenation would be very much appriciated. //A noob programer whos first language is C++.