For Statement: The Second Form of For
Learn the second form of the for statement and cases when we need it.
We'll cover the following
The second form of for
The second form of the for
statement allows us to apply an arithmetic expression as a condition. Let’s consider cases when we need the second form.
Let’s suppose that we write a script for calculating a factorial. The solution for this task depends on the way we enter the data. The first option is that we have a predefined integer. Then, we can apply the first form of the for
loop. The for-factorial-brace.sh
shows this solution.
Let’s click on the “Run” button and then execute the file. If we made any changes in the file, click on the “Run” button again before executing the file.
Get hands-on with 1200+ tech skills courses.