For Loop

Suleiman Abdullah
2 min readMay 26, 2024

Objective: Understand for Loop.

For Loop is used for iteration ,meaning it will repeatedly execute a statement , if the expression condition is true.

Syntax for for loop ,it start with for keyword ,double parentheses ,open and closing curly bracket.

for(Iteration expression)
//code go here

How do we specify iteration in the for loop.

We use expressions to evaluate conditions, perform calculations

To do this inside double parenthesis we define a value of int and its name as i(Index), then we initialize it to zero ,then check our if our index is less than maxValue then end with semi colon, this max value is total number will let our program run. After program execute will increment i(Index) by one .

for(int i =0,i<3;i++)


Evaluation and Calculation Order

Initial step it is Initialization ,then it check if i the less than 3 then the statement inside the curly bracket run.

Next time it Increment i by 1 ,then check if i is less than maxValue(3),if the condition is false we run the code .

For loop will stop when the condition is true.

Note: I use Debug.Log to display string in the console , to display both string and value we concatenate string with i using plus sign. Debug outside a loop will get called when loop execution finish.

This is the Introduction of for loop

see you in the next one.



Suleiman Abdullah

Self taught Unity Developer, who is passion about making games ,and he loves Math For Game Development