Same looping behavior.
Now we will look over the syntax for loop, here for loop looks similar to all other
In the above loop first statement will initializing the variable, the second statement will check the condition just like while loop, and third statement will control the loop ex: incrementing or decrementing the variable values.
Here in the above example the loop counter will initialized as part of the loop itself.
The loop check for an expression to see if another loop is execute, after body code is executed the final expression is executed before moving on, this statement will affect weather to run loop again.
Before another loop the middle expression will check again.
Now we will check another if and else code based on specific conditions.
Syntax for if and else condition.
If the condition evaluates to true, the if code block will execute code inside the if block.
Else follows up with code to execute only when the if condition is not satisfied, it is ignored otherwise.
Now we will look over the nested if and else conditions below, syntax for nested if else conditions.
As soon as condition is met in any block, the rest of the condition will be skipped completely and print the output of particular executed condition.
Elseif is mostly used to check multiple conditions easily
Now we will check the multiple conditions using else if as below
Thanks for reading this article