Asked in
Computer Programming
C Programming

How does the for loop work in c?


User Avatar
Wiki User
January 29, 2009 3:10AM

for(initialization; condition; end_action) {



* initialization - used to initialize variables (usually something like i = 0)

* condition - boolean expression; loop continues while expression is met

* end_action - action to perform at the end of the loop (usually something like i++)

* code - code to repeat Note that any of the above sections can be empty:


This is a valid code block which will do nothing and never finish.